* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #ffffff;
  color: #111111;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}
#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- 登录 ---------- */
.login-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 16px;
}
.login-screen h1 {
  font-size: 1.4rem;
  color: #111111;
  margin-bottom: 8px;
}
.login-screen input {
  width: 100%;
  max-width: 320px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111111;
  font-size: 1rem;
}
.login-screen button {
  width: 100%;
  max-width: 320px;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: #3b7cf6;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
}
.login-screen button:active { background: #2f63c9; }
.login-error { color: #dc2626; font-size: 0.9rem; min-height: 1.2em; }

/* ---------- 顶部栏 ---------- */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  gap: 10px;
}
.topbar .back-btn {
  background: none;
  border: none;
  color: #3b7cf6;
  font-size: 1.3rem;
  padding: 0 6px;
  display: none;
}
.topbar h1 {
  font-size: 1.1rem;
  margin: 0;
  color: #111111;
  flex: 1;
}
.topbar .icon-btn {
  width: 32px;
  height: 32px;
  font-size: 1.1rem;
}

/* ---------- 微信收件箱入口 ---------- */
.wechat-entry {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 12px 0;
  padding: 10px 14px;
  background: #f7f8fa;
  border-radius: 12px;
  color: #111111;
  font-size: 0.95rem;
}
.wechat-badge {
  background: #ff5555;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 8px;
  min-width: 20px;
  text-align: center;
}

/* ---------- 新建项目 弹窗 ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal {
  background: #f7f8fa;
  border-radius: 14px;
  padding: 20px;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal h2 { margin: 0; color: #111111; font-size: 1.1rem; }
.modal input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111111;
  font-size: 0.95rem;
}
.modal-error { color: #dc2626; font-size: 0.85rem; min-height: 1.1em; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions button {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: #f3f4f6;
  color: #111111;
}
.modal-actions button.primary { background: #3b7cf6; color: #fff; }

/* ---------- 微信收件箱列表 ---------- */
.wechat-list { flex: 1; overflow-y: auto; padding: 12px; }
.wechat-item {
  display: flex;
  gap: 12px;
  background: #f7f8fa;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
}
.wechat-item.assigned { opacity: 0.55; }
.wechat-item-preview {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  border-radius: 8px;
  overflow: hidden;
  background: #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wechat-item-preview img { width: 100%; height: 100%; object-fit: cover; }
.wechat-item-preview .file-icon { font-size: 1.6rem; }
.wechat-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.wechat-item-name { color: #111111; font-size: 0.9rem; word-break: break-all; }
.wechat-item-meta { color: #6b7280; font-size: 0.75rem; }
.wechat-item-actions { display: flex; gap: 8px; margin-top: 4px; }
.assign-select {
  flex: 1;
  background: #ffffff;
  color: #111111;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 4px 6px;
  font-size: 0.8rem;
}
.wechat-send-btn {
  border: none;
  border-radius: 8px;
  background: #3b7cf6;
  color: #fff;
  padding: 4px 10px;
  font-size: 0.8rem;
}
.wechat-send-btn:disabled { opacity: 0.5; }

/* ---------- 聊天图片上的发到微信按钮 ---------- */
.msg-image-wrap { position: relative; display: inline-block; }
.img-send-wechat {
  position: absolute;
  bottom: 4px;
  right: 4px;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- 项目列表 ---------- */
.project-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  -webkit-overflow-scrolling: touch;
}
.project-card {
  background: #f7f8fa;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  active-opacity: 0.8;
}
.project-card:active { background: #eceef1; }
.project-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #16a34a;
  flex: 0 0 auto;
}
.status-dot.warn { background: #f5a623; }
.project-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: #111111;
  flex: 1;
}
.pending-badge {
  background: #f5a623;
  color: #111111;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 9px;
}
.project-meta {
  font-size: 0.85rem;
  color: #6b7280;
  display: flex;
  justify-content: space-between;
}
.empty-hint {
  text-align: center;
  color: #9ca3af;
  padding: 40px 20px;
}

.unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff5555;
  flex: 0 0 auto;
}
.card-action-btn {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
  margin: -10px -8px -10px 0;
  border: none;
  background: transparent;
  color: #6b7280;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-action-btn.move-out-btn {
  font-size: 0.85rem;
  color: #3b7cf6;
  min-width: 44px;
}
.project-preview {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.85rem;
}
.preview-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-text.from-assistant { color: #6b7280; }
.preview-text.from-user { color: #374151; }
.preview-time {
  flex: 0 0 auto;
  color: #9ca3af;
  font-size: 0.75rem;
}

/* ---------- 不常用项目文件夹 ---------- */
.folder-section { margin-top: 4px; }
.folder-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f7f8fa;
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 12px;
  min-height: 44px;
  color: #111111;
}
.folder-icon { font-size: 1.1rem; }
.folder-name { flex: 1; font-size: 0.95rem; }
.folder-caret { color: #9ca3af; }
.folder-members .project-card { margin-left: 10px; }

/* ---------- 底部弹出式操作菜单 ---------- */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: flex-end;
  z-index: 1000;
}
.sheet {
  width: 100%;
  background: #f7f8fa;
  border-radius: 16px 16px 0 0;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
.sheet-item {
  min-height: 48px;
  border: none;
  background: transparent;
  color: #111111;
  font-size: 1rem;
  border-radius: 10px;
}
.sheet-item:active { background: #f3f4f6; }
.sheet-cancel { color: #6b7280; margin-top: 4px; border-top: 1px solid #e5e7eb; border-radius: 0; }

/* ---------- 对话 ---------- */
.chat-topbar h1 { margin-left: 44px; }
.chat-topbar-btn {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  border: none;
  background: #f3f4f6;
  color: #4b5563;
  font-size: 0.8rem;
  white-space: nowrap;
}
.chat-topbar-btn:active { background: #e5e7eb; }
.msg-divider {
  align-self: center;
  display: flex;
  align-items: center;
  margin: 10px 0;
  font-size: 0.72rem;
  color: #9ca3af;
}
.session-modal { max-width: 360px; }
.session-row-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; }
.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  background: #f3f4f6;
  color: #111111;
  font-size: 0.9rem;
  text-align: left;
}
.session-row.current { background: #dce8ff; color: #14356b; }
.session-row-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.session-row-time { flex: 0 0 auto; font-size: 0.75rem; color: #6b7280; }
.session-row.current .session-row-time { color: #3b5c99; }
.float-back-btn {
  position: fixed;
  top: 12px;
  left: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #111111;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  z-index: 500;
  transition: background-color 0.2s ease;
}
.float-back-btn:active { background: #f3f4f6; }
.float-back-btn.scrolled { background: #ffffff; border-color: #d1d5db; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); }
.chat-screen { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 64px 14px 14px;
  padding-bottom: 80px;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.msg {
  position: relative;
  max-width: 88%;
  padding: 3px 8px 0;
  border-radius: 10px;
  font-size: 0.95rem;
  line-height: 1.3;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-status-badge {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
  color: #6b7280;
  white-space: normal;
}
.msg.user {
  align-self: flex-end;
  background: #dce8ff;
  color: #14356b;
  border-bottom-right-radius: 4px;
}
.msg.assistant {
  align-self: flex-start;
  background: #f1f3f5;
  color: #111111;
  border-bottom-left-radius: 4px;
}
.msg-time {
  display: block;
  font-size: 0.6rem;
  line-height: 1;
  color: #9ca3af;
  margin: 1px 0 -1px;
  text-align: right;
}
.msg-time.inline {
  display: inline;
  margin-left: 6px;
  font-size: 0.6rem;
  vertical-align: baseline;
  white-space: nowrap;
}
.msg.user .msg-time { color: #5c7ab5; }
.msg-images {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
  margin-bottom: 0;
}
.msg-images img {
  width: 110px;
  height: 110px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
}
.msg.pending {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 84px;
  opacity: 1;
}
.msg.pending .msg-status-badge { margin-top: 0; }
.msg-stream-text:empty { display: none; }
.msg.error { background: #fdecea; color: #dc2626; }
.thinking-dots::after {
  content: "";
  animation: thinking-ellipsis 1.2s steps(4, end) infinite;
}
@keyframes thinking-ellipsis {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
  100% { content: ""; }
}

.msg-attachments {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 3px;
  margin-bottom: 0;
}
.attachment-card {
  display: flex;
  gap: 10px;
  align-items: center;
  background: rgba(0,0,0,0.05);
  border-radius: 10px;
  padding: 8px 10px;
}
.msg.user .attachment-card { background: rgba(20,53,107,0.06); }
.attachment-preview {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 8px;
  overflow: hidden;
  background: #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
}
.attachment-preview img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.attachment-icon { font-size: 1.4rem; }
.attachment-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.attachment-name { font-size: 0.82rem; word-break: break-all; }
.attachment-size { font-size: 0.72rem; opacity: 0.75; }
.attachment-actions { display: flex; gap: 8px; margin-top: 2px; }
.attachment-dl, .attachment-send-wechat {
  border: none;
  border-radius: 6px;
  background: #3b7cf6;
  color: #fff;
  padding: 3px 9px;
  font-size: 0.72rem;
  text-decoration: none;
  line-height: 1.6;
}
.attachment-send-wechat:disabled { opacity: 0.5; }

.composer-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 400;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
  padding-bottom: calc(env(safe-area-inset-bottom) + 8px);
}
.chat-input-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
}
.chat-input-bar textarea {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 12px;
  border-radius: 18px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111111;
  font-size: 0.95rem;
  font-family: inherit;
}
.icon-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #f3f4f6;
  color: #4b5563;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn.send { background: #3b7cf6; color: #fff; }
.icon-btn:disabled { opacity: 0.5; }

.pending-upload-strip {
  display: flex;
  gap: 6px;
  padding: 0 12px 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.pending-upload-strip .thumb {
  position: relative;
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
}
.pending-upload-strip .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}
.pending-upload-strip .file-chip {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 54px;
  max-width: 150px;
  padding: 0 20px 0 8px;
  border-radius: 8px;
  background: #f3f4f6;
  white-space: nowrap;
}
.pending-upload-strip .file-chip-icon { font-size: 1.1rem; flex: 0 0 auto; }
.pending-upload-strip .file-chip-name {
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pending-upload-strip .file-chip-size {
  font-size: 0.68rem;
  opacity: 0.7;
  flex: 0 0 auto;
}
.pending-upload-strip .thumb .rm,
.pending-upload-strip .file-chip .rm {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ff5555;
  color: #fff;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- 全屏图片预览 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}
.lightbox img { max-width: 94vw; max-height: 94vh; }

.hidden { display: none !important; }

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(17,17,17,0.9);
  color: #fff;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  z-index: 1000;
}

/* ---------- 附件底部菜单 ---------- */
.action-sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: flex;
  align-items: flex-end;
  z-index: 1100;
}
.action-sheet {
  width: 100%;
  background: #fff;
  border-radius: 14px 14px 0 0;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.action-sheet button {
  min-height: 46px;
  font-size: .95rem;
  border: none;
  border-radius: 10px;
  background: #f7f8fa;
  color: #111;
  cursor: pointer;
}
.action-sheet button.cancel { background: #fff; color: #666; border-top: 1px solid #eee; }

/* WEBAPP-31 后台任务运行中 */
.run-actor {
  width: 18px; height: 18px; flex: 0 0 auto;
  vertical-align: middle;
  border-radius: 4px;
  image-rendering: pixelated;
}


/* 轻问答 /ask（WEBAPP-35）：浅黄底 + 左侧 2px 虚线；user 气泡右上角小标签 */
.msg.assistant.ask { background: #fff8e6; border-left: 2px dashed #d9a441; color: inherit; }
.msg.assistant.ask.error { background: #fff8e6; color: inherit; }
.msg.user.ask { position: relative; margin-top: 8px; }
.msg.user.ask::before {
  content: "轻问答";
  position: absolute; top: -8px; right: 8px;
  font-size: 10px; line-height: 1; padding: 2px 6px;
  border-radius: 8px; background: #fff8e6; color: #9a6b12; border: 1px solid #ecd9a8;
}
