/* 豆包同款纯净浅色移动端设计系统 */
:root {
  --bg-page: #ffffff;
  --bg-subtle: #f6f7f9;
  --bg-pill: #ffffff;
  --bg-active: #f1f2f5;
  --bg-user-bubble: #f3f4f6;
  --text-main: #18191c;
  --text-secondary: #61666d;
  --text-muted: #9499a0;
  --border-light: #ebedf0;
  --accent-blue: #2563eb;
  --accent-green: #16a34a;
  --shadow-capsule: 0 6px 24px rgba(15, 23, 42, 0.08), 0 1px 4px rgba(15, 23, 42, 0.04);
  --shadow-pill: 0 2px 8px rgba(15, 23, 42, 0.04);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #eef0f4;
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  overflow: hidden;
  user-select: none;
}

/* 电脑端打开时自动居中展示手机视窗，手机端 100% 铺满全屏 */
.app-shell {
  position: relative;
  width: 100%;
  max-width: 520px;
  height: 100%;
  margin: 0 auto;
  background: var(--bg-page);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.08);
}

@media (max-width: 600px) {
  .app-shell {
    max-width: 100%;
    box-shadow: none;
  }
}

/* ==================== 顶部导航栏 (豆包同款) ==================== */
.top-header {
  padding-top: calc(var(--safe-top) + 8px);
  padding-bottom: 8px;
  padding-left: 12px;
  padding-right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(235, 237, 240, 0.6);
  z-index: 20;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.icon-btn:active, .icon-btn:hover {
  background: var(--bg-active);
}

.icon-btn.active-blue {
  color: var(--accent-blue);
  background: #eff6ff;
}

.header-center {
  flex: 1;
  min-width: 0;
  text-align: center;
  padding: 0 6px;
  cursor: pointer;
}

.conv-title-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  max-width: 100%;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.conv-title-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.net-subtitle {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #16a34a;
  display: inline-block;
}

.status-dot.relay {
  background: #2563eb;
}

.status-dot.offline {
  background: #ef4444;
}

/* ==================== 主聊天消息流 ==================== */
.chat-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 24px;
  scroll-behavior: smooth;
  user-select: text;
}

.chat-viewport::-webkit-scrollbar {
  width: 4px;
}
.chat-viewport::-webkit-scrollbar-thumb {
  background: #e2e5ea;
  border-radius: 4px;
}

.msg-row {
  margin-bottom: 22px;
  animation: fadeIn 0.18s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.user-bubble {
  max-width: 84%;
  background: var(--bg-user-bubble);
  color: var(--text-main);
  padding: 11px 15px;
  border-radius: 20px 20px 6px 20px;
  font-size: 16px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.att-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
  justify-content: flex-end;
}

.att-chip {
  font-size: 12px;
  background: #eff6ff;
  color: #1d4ed8;
  padding: 4px 10px;
  border-radius: 12px;
}

/* 豆包同款大字重清爽阅读排版 */
.ai-container {
  width: 100%;
  font-size: 16px;
  line-height: 1.72;
  color: var(--text-main);
}

.ai-markdown h1, .ai-markdown h2, .ai-markdown h3, .ai-markdown h4 {
  margin: 14px 0 8px;
  font-weight: 700;
  line-height: 1.38;
  color: #111827;
}
.ai-markdown h3 { font-size: 18px; }
.ai-markdown p { margin: 8px 0; }
.ai-markdown ul, .ai-markdown ol {
  margin: 8px 0;
  padding-left: 20px;
}
.ai-markdown li {
  margin: 6px 0;
}
.ai-markdown blockquote {
  margin: 10px 0;
  padding: 8px 12px;
  border-left: 3px solid #cbd5e1;
  background: #f8fafc;
  color: #475569;
  border-radius: 0 8px 8px 0;
  font-size: 14px;
}
.ai-markdown code.inline-code {
  background: #f1f3f6;
  padding: 2px 6px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  color: #0f172a;
}
.code-block-wrap {
  margin: 12px 0;
  background: #f7f8fa;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
}
.code-block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: #eef0f4;
  font-size: 12px;
  color: #64748b;
}
.code-copy-btn {
  border: none;
  background: transparent;
  color: #2563eb;
  font-size: 12px;
  cursor: pointer;
}
.code-block-wrap pre {
  margin: 0;
  padding: 12px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* 思考过程与工具折叠框 */
.thought-box {
  margin-bottom: 10px;
  border: 1px solid #ebedf0;
  background: #fafbfc;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-secondary);
}
.thought-box summary {
  cursor: pointer;
  font-weight: 500;
  user-select: none;
}
.thought-content {
  margin-top: 6px;
  white-space: pre-wrap;
  color: #64748b;
  font-size: 12.5px;
}

.msg-footer {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}
.msg-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mini-action-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
}
.mini-action-btn:hover { color: var(--text-main); }

/* 悬浮回到底部圆形按钮 (复刻豆包截图) */
.scroll-bottom-fab {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 136px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 15;
}
.scroll-bottom-fab.visible {
  display: flex;
}

/* ==================== 底部豆包功能胶囊条 + 输入舱 ==================== */
.bottom-dock {
  background: linear-gradient(180deg, rgba(255,255,255,0) 0%, #ffffff 18%);
  padding: 6px 12px calc(var(--safe-bottom) + 10px);
  z-index: 20;
}

.action-pills-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 10px;
  scrollbar-width: none;
}
.action-pills-bar::-webkit-scrollbar {
  display: none;
}

.action-pill {
  flex-shrink: 0;
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid #e6e8ec;
  background: #ffffff;
  box-shadow: var(--shadow-pill);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.action-pill:active {
  background: var(--bg-active);
}
.action-pill .chevron {
  color: #9ca3af;
  font-size: 12px;
}

/* 待发送附件预览条 */
.pending-atts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0 4px 8px;
}
.pending-att-item {
  background: #f1f5f9;
  border-radius: 10px;
  padding: 4px 10px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* 豆包标志性大圆角底部胶囊 */
.input-capsule {
  min-height: 54px;
  border-radius: 28px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  box-shadow: var(--shadow-capsule);
  display: flex;
  align-items: center;
  padding: 5px 8px;
  gap: 6px;
}

.capsule-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #1f2329;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}
.capsule-icon-btn:active {
  background: var(--bg-active);
}

/* 按住说话按钮 (复刻豆包居中粗体样式) */
.hold-talk-btn {
  flex: 1;
  height: 42px;
  border: none;
  border-radius: 21px;
  background: transparent;
  color: #111827;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.hold-talk-btn.recording {
  background: #eff6ff;
  color: #2563eb;
}

.text-input-field {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-size: 15.5px;
  line-height: 1.45;
  max-height: 110px;
  padding: 8px 4px;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
}
.text-input-field::placeholder {
  color: #9ca3af;
}

.send-circle-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: #2563eb;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}
.send-circle-btn.stop {
  background: #ef4444;
}

/* ==================== 左侧滑出抽屉 (1:1 豆包侧边栏) ==================== */
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  z-index: 40;
}
.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-drawer {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 82%;
  max-width: 330px;
  background: #ffffff;
  transform: translateX(-102%);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 50;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
.sidebar-drawer.open {
  transform: translateX(0);
}

.drawer-top {
  padding: 16px 18px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.drawer-brand {
  font-size: 20px;
  font-weight: 700;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 8px;
}
.host-tag {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 99px;
  background: #ecfdf5;
  color: #059669;
}
.host-tag.relay {
  background: #eff6ff;
  color: #2563eb;
}

.drawer-search-box {
  margin: 0 14px 8px;
  display: none;
}
.drawer-search-box.show {
  display: block;
}
.drawer-search-input {
  width: 100%;
  height: 36px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #f7f8fa;
  padding: 0 12px;
  font-size: 14px;
  outline: none;
}

.drawer-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 64px;
}

.drawer-section-label {
  padding: 10px 10px 6px;
  font-size: 12.5px;
  color: #9499a0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 10px;
  border-radius: 12px;
  cursor: pointer;
  margin-bottom: 2px;
}
.drawer-item:hover, .drawer-item:active {
  background: #f6f7f9;
}
.drawer-item.active {
  background: #f2f3f5;
  font-weight: 600;
}

/* 豆包标志性浅绿电脑圆标与浅蓝气泡圆标 */
.item-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.item-badge.green-pc {
  background: radial-gradient(circle at 30% 30%, #ebfef2, #d3f8e2);
  color: #16a34a;
  border: 1px solid #bbf7d0;
}
.item-badge.blue-chat {
  background: radial-gradient(circle at 30% 30%, #eff6ff, #dbeafe);
  color: #3b82f6;
  border: 1px solid #bfdbfe;
}
.item-badge.plain-folder {
  background: #f3f4f6;
  color: #4b5563;
}

.item-title {
  flex: 1;
  font-size: 15px;
  color: #18191c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-more-btn {
  border: none;
  background: transparent;
  color: #9ca3af;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}

/* 悬浮“回到主对话”胶囊 (复刻豆包截图) */
.back-main-pill {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 68px);
  height: 38px;
  padding: 0 16px 0 10px;
  border-radius: 99px;
  background: #ffffff;
  border: 1px solid #ebedf0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: #18191c;
  cursor: pointer;
}

.drawer-footer {
  border-top: 1px solid #f0f1f4;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
}
.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #10b981);
  color: #ffffff;
  font-weight: 700;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-meta-name {
  font-size: 14.5px;
  font-weight: 600;
  color: #18191c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-meta-sub {
  font-size: 11.5px;
  color: #9499a0;
}

/* ==================== 底部半屏弹窗 (模型选择 / 双网配置 / 文件夹浏览) ==================== */
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.36);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 60;
  display: flex;
  align-items: flex-end;
}
.sheet-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.bottom-sheet {
  width: 100%;
  max-height: 82%;
  background: #ffffff;
  border-radius: 22px 22px 0 0;
  padding: 14px 16px calc(var(--safe-bottom) + 18px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform 0.22s ease-out;
}
.sheet-backdrop.open .bottom-sheet {
  transform: translateY(0);
}
.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 4px;
  background: #dcdfe6;
  margin: 0 auto 12px;
}
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.sheet-title {
  font-size: 16.5px;
  font-weight: 700;
}
.sheet-body {
  overflow-y: auto;
  flex: 1;
}

.option-card {
  border: 1px solid #ebedf0;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.option-card.selected {
  border-color: #2563eb;
  background: #f5f9ff;
}
.badge-tag {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  background: #eef2ff;
  color: #3730a3;
  margin-left: 6px;
}

.effort-group {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.effort-btn {
  flex: 1;
  padding: 9px 6px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.effort-btn.selected {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.form-group {
  margin-bottom: 12px;
}
.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #4b5563;
  margin-bottom: 5px;
}
.form-input {
  width: 100%;
  height: 40px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  padding: 0 12px;
  font-size: 14px;
  outline: none;
}
.form-input:focus {
  border-color: #2563eb;
}

.primary-btn {
  width: 100%;
  height: 42px;
  border: none;
  border-radius: 12px;
  background: #2563eb;
  color: #ffffff;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
}
.secondary-btn {
  height: 38px;
  padding: 0 14px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #ffffff;
  color: #1f2937;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}

/* ==================== 豆包同款全屏实时语音通话层 ==================== */
.voice-call-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  z-index: 80;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 32px) 24px calc(var(--safe-bottom) + 40px);
}
.voice-call-overlay.open {
  display: flex;
}
.voice-orb {
  width: 148px;
  height: 148px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #60a5fa, #2563eb 55%, #10b981 100%);
  box-shadow: 0 0 60px rgba(59, 130, 246, 0.55);
  animation: pulseOrb 2.4s infinite ease-in-out;
}
@keyframes pulseOrb {
  0%, 100% { transform: scale(0.95); opacity: 0.9; }
  50% { transform: scale(1.08); opacity: 1; }
}
.hangup-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: #ef4444;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
