* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #EFF2F5;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  color: #111827;
}
button, textarea, [contenteditable] { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: #EFF2F5;
}
.navbar {
  height: 64px;
  min-height: 64px;
  background: #fff;
  display: flex;
  align-items: center;
  padding: 0 8px 0 4px;
  flex-shrink: 0;
  padding-top: env(safe-area-inset-top);
  min-height: calc(64px + env(safe-area-inset-top));
}
.nav-back {
  width: 32px;
  height: 44px;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #1f2937;
}
.nav-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-right: 12px;
}
.nav-title {
  min-width: 0;
  max-width: min(58vw, 260px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 600;
  line-height: 20px;
  color: #111827;
}
.chat-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 12px 12px 16px;
  color: #666;
}
.time {
  text-align: center;
  font-size: 12px;
  color: #999;
  margin: 10px 0 14px;
}
.row {
  display: flex;
  align-items: flex-start;
  margin-bottom: 14px;
  gap: 8px;
}
.row.me {
  flex-direction: row-reverse;
  padding-left: 48px;
}
.row.agent { padding-right: 48px; }
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.bubble {
  max-width: 76%;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
  border-radius: 6px;
  padding: 8px;
}
.row.agent .bubble { background: #fff; color: #111; }
.row.me .bubble { background: #FFE62F; color: #111; }
.faq-card {
  width: 83.333%;
  margin: 8px 0 16px;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
}
.faq-title {
  padding: 12px 16px;
  font-size: 14px;
  color: #111;
  white-space: pre-line;
  border-bottom: 1px solid #f2f3f5;
  line-height: 1.6;
}
.faq-item {
  display: flex;
  align-items: flex-start;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  color: #3b82f6;
  font-size: 14px;
  padding: 12px 16px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.5;
}
.faq-item:active { opacity: .65; }
.faq-num { font-weight: 700; padding-right: 8px; flex-shrink: 0; }
.composer {
  flex-shrink: 0;
  background: #fff;
  box-shadow: 0 -4px 18px rgba(15, 23, 42, 0.08);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #e2e8f0;
  padding: 8px;
  max-height: 160px;
}
.input-box {
  flex: 1;
  min-height: 32px;
  max-height: 128px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 6px 8px;
  font-size: 16px;
  line-height: 1.4;
  outline: none;
  word-break: break-all;
}
.input-box:empty:before {
  content: attr(data-placeholder);
  color: #9ca3af;
}
.composer-tools {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 6px;
  height: 32px;
  flex: none;
  width: auto;
  min-width: 80px;
}
.icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  padding: 0;
}
.icon-btn img { width: 32px; height: 32px; display: block; }
.send-btn {
  height: 28px;
  min-width: 52px;
  border: 0;
  border-radius: 4px;
  background: #FFE62F;
  color: #111;
  font-size: 14px;
  font-weight: 500;
  padding: 0 10px;
}
.send-btn.hidden, .icon-btn.hidden, .hidden { display: none !important; }
.emoji-panel {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  padding: 8px;
  background: #f1f5f9;
  max-height: 208px;
  overflow-y: auto;
}
.emoji-panel button {
  height: 36px;
  border: 0;
  background: transparent;
  font-size: 22px;
}
.blocked {
  position: fixed;
  inset: 0;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
  color: #666;
  z-index: 50;
}
html.is-phone .composer {
  position: sticky;
  bottom: 0;
}
