/* 访客客服页：移动优先，桌面居中卡片 */
.service-body { background: var(--soft); }

.service-main { padding: 32px 16px 60px; }

.service-shell {
  max-width: 860px; margin: 0 auto; background: #fff; border: 1px solid var(--line);
  border-radius: 18px; overflow: hidden; box-shadow: 0 18px 50px rgba(16, 24, 40, .08);
  display: flex; flex-direction: column; min-height: 640px;
}

.service-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 22px; border-bottom: 1px solid var(--line); background: #fff;
}
.service-head strong { font-size: 16px; color: var(--ink); }
.service-status { display: inline-flex; align-items: center; gap: 6px; margin-left: 10px; font-size: 12px; color: #16a34a; }
.service-status .dot { width: 7px; height: 7px; border-radius: 50%; background: #16a34a; display: inline-block; }
.service-status.offline { color: #9ca3af; }
.service-status.offline .dot { background: #9ca3af; }
.service-head-links { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.service-head-links a:hover { color: var(--red); }

.service-join { padding: 34px 30px 40px; max-width: 520px; margin: 0 auto; width: 100%; }
.service-join h1 { font-size: 26px; }
.service-join .field { margin-bottom: 14px; }
.service-join .btn { width: 100%; margin-top: 6px; }
.service-error { color: #b91c1c; font-size: 14px; min-height: 20px; margin: 10px 0 0; }

.service-room { display: flex; flex-direction: column; flex: 1; min-height: 0; }
/* 上面这行 display:flex 会盖掉浏览器默认的 [hidden]{display:none}，
   没进会话时聊天区照样占着三百多像素，表单底下挂一个空聊天框。
   这里把 hidden 的优先级补回来。 */
.service-room[hidden] { display: none; }

.service-messages {
  flex: 1; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 14px;
  background: linear-gradient(180deg, #fbfbfc 0%, #fff 100%); min-height: 360px; max-height: 58vh;
}

.svc-row { display: flex; gap: 10px; align-items: flex-end; }
.svc-row.out { flex-direction: row-reverse; }
.svc-avatar {
  flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%; overflow: hidden;
  background: #eceef2; color: #6b7280;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.svc-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.svc-row.out .svc-avatar { background: var(--red); color: #fff; }
.svc-main { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: 74%; }
.svc-row.out .svc-main { align-items: flex-end; }
.svc-bubble {
  max-width: 100%; padding: 11px 14px; border-radius: 14px; background: #fff;
  border: 1px solid var(--line); font-size: 15px; line-height: 1.6; word-break: break-word;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.svc-row.out .svc-bubble { background: var(--red); border-color: var(--red); color: #fff; }
.svc-bubble img { border-radius: 10px; max-width: 220px; cursor: zoom-in; }
.svc-time { font-size: 11px; color: #9ca3af; margin-top: 4px; }
.svc-row.out .svc-time { text-align: right; }
.svc-recalled { font-style: italic; color: #9ca3af; }

.service-composer {
  display: flex; gap: 10px; align-items: flex-end; padding: 12px 16px; border-top: 1px solid var(--line);
  background: #fff;
}
.service-composer textarea {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; font: inherit;
  /* 16px 是 iOS 聚焦不自动放大的下限，低于它整页会被撑大且缩不回来 */
  font-size: 16px; resize: none; max-height: 120px; min-height: 44px; outline: none;
  background: #fafbfc;
}
.service-composer textarea:focus { background: #fff; }
.service-composer textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(230, 0, 18, .08); }
.service-tool { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 18px; }

.service-room-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 8px 18px 12px; font-size: 12px; color: var(--muted);
}
.link-btn { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 12px; text-decoration: underline; }
.link-btn:hover { color: var(--red); }

.service-lightbox {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .78); display: flex; align-items: center;
  justify-content: center; z-index: 999; padding: 24px; cursor: zoom-out;
}
.service-lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 10px; }

@media (max-width: 768px) {
  .service-main { padding: 0; }
  .service-shell { border-radius: 0; border: 0; min-height: calc(100vh - 60px); box-shadow: none; }
  .service-head { padding: 12px 16px; }
  .service-head-links { display: none; }
  .service-join { padding: 24px 18px 32px; }
  .service-messages { max-height: none; padding: 16px; }
  .svc-main { max-width: 80%; }
}

/* ============ 嵌入模式（/service/?embed=1） ============
   被客服浮层用 iframe 装进来时，外面已经有标题栏了，
   这里只保留聊天本身，并且撑满 iframe 高度。 */
html.is-embed,
html.is-embed body.service-body { height: 100%; }
html.is-embed body.service-body { background: #fff; }
html.is-embed #site-header,
html.is-embed #site-footer,
html.is-embed .service-head { display: none; }
html.is-embed .service-main { padding: 0; height: 100%; }
html.is-embed .service-shell {
  max-width: none; height: 100%; min-height: 0;
  border: 0; border-radius: 0; box-shadow: none;
  /* 外壳撑满 iframe，内容比它高时在壳内滚动。
     基础样式是 overflow:hidden，嵌入后会把「开始咨询」下面那行说明直接裁掉，
     而且文档高度正好等于 iframe 高度，外层也滚不动，等于永远看不到。 */
  overflow-y: auto; overscroll-behavior: contain;
}
html.is-embed .service-join { padding: 26px 22px 30px; }
html.is-embed .service-messages { max-height: none; }
