/* 独立对话链接的访客界面。嵌入式聊天仍使用渠道面板样式。 */
body.visitor-link-chat {
  --chat-page: #f8f9fb;
  --chat-surface: #fff;
  --chat-soft: #f2f3f5;
  --chat-line: #e1e4ea;
  --chat-ink: #18202d;
  --chat-muted: #626c7b;
  --chat-accent: #2563eb;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  margin: 0;
  background: var(--chat-page);
  color: var(--chat-ink);
}

.visitor-link-chat.fangke-you-cebian { display: flex; }

.visitor-link-chat .fangke-chuang {
  box-sizing: border-box;
  width: min(var(--fangke-link-width, 450px), calc(100% - 32px));
  height: min(var(--fangke-link-height, 600px), calc(100dvh - 32px));
  overflow: hidden;
  border: 1px solid var(--chat-line);
  border-radius: 20px;
  background: var(--chat-surface);
  color: var(--chat-ink);
  box-shadow: 0 8px 28px #18202d0a;
}

.visitor-link-chat .fangke-chuang > header {
  flex: 0 0 auto;
  height: auto;
  min-height: 60px;
  gap: 12px;
  padding: 10px 12px 10px 15px;
  border-bottom: 1px solid var(--chat-line);
  background: var(--chat-surface);
  color: var(--chat-ink);
}

.visitor-link-chat .fangke-chuang > header > div { flex: 1; min-width: 0; }
.visitor-link-chat .fangke-chuang > header b { font-size: 17px; line-height: 1.35; overflow-wrap: anywhere; }
.visitor-link-chat .fangke-chuang > header small { margin-top: 2px; color: var(--chat-muted); font-size: 12px; opacity: 1; }
.visitor-link-chat .fangke-chuang > header i { vertical-align: 1px; background: #229450; }
.fangke-chuang #fangke-zhuangtai[data-status="away"] i { background: #79869a; }
.fangke-chuang #fangke-zhuangtai[data-status="waiting"] i { background: #b76a13; }

.visitor-link-chat .fangke-toubu-touxiang {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #e8f0ff;
  color: var(--chat-accent);
  font-size: 0;
}

.visitor-link-chat .fangke-toubu-touxiang::before,
.visitor-link-chat .fangke-gongju label::before,
.visitor-link-chat #fangke-fasong::before {
  content: "";
  width: 20px;
  height: 20px;
  background: currentColor;
  mask: var(--chat-icon) center / contain no-repeat;
}

.visitor-link-chat .fangke-toubu-touxiang { --chat-icon: url("官网/service.svg"); }
.visitor-link-chat .fangke-gongju label { --chat-icon: url("访客图标/paperclip.svg"); }
.visitor-link-chat #fangke-fasong { --chat-icon: url("访客图标/send.svg"); }

.visitor-link-chat .fangke-shouqi {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 10px;
  color: var(--chat-muted);
  cursor: pointer;
}

.visitor-link-chat .fangke-chuang > section {
  min-height: 0;
  padding: 16px 17px;
  background: var(--chat-surface);
  overscroll-behavior: contain;
}

.visitor-link-chat .fangke-shijian {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 14px;
  padding: 3px 9px;
  border-radius: 7px;
  background: #f6f7f9;
  color: var(--chat-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.visitor-link-chat .fangke-welcome {
  box-sizing: border-box;
  width: 83%;
  margin: 0 0 14px;
  padding: 9px;
  border-radius: 15px;
  background: var(--chat-soft);
}

.visitor-link-chat .fangke-welcome p {
  margin: 1px 3px 8px;
  color: var(--chat-ink);
  font-size: 16px;
  line-height: 1.55;
}
.visitor-link-chat .fangke-welcome:has(.yushe-wenti:empty) p { margin-bottom: 1px; }
.visitor-link-chat .yushe-wenti { display: grid; gap: 6px; padding: 0; overflow: visible; }
.visitor-link-chat .yushe-wenti:empty { display: none; }

.visitor-link-chat .yushe-wenti button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding: 7px 12px;
  border: 0;
  border-radius: 11px;
  background: var(--chat-surface);
  color: var(--chat-ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}

.visitor-link-chat .yushe-wenti button::after {
  content: "";
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  background: var(--chat-muted);
  mask: url("访客图标/chevron-right.svg") center / contain no-repeat;
}

.visitor-link-chat .fangke-shouqi:hover,
.visitor-link-chat .fangke-gongju label:hover { background: var(--chat-soft); }
.visitor-link-chat .yushe-wenti button:hover { background: #e9edf3; }

.visitor-link-chat .fangke-chuang .xiaoxi .paopao {
  border: 0;
  border-radius: 13px;
  box-shadow: none;
  background: var(--chat-soft);
  color: var(--chat-ink);
  overflow-wrap: anywhere;
}
.visitor-link-chat .fangke-chuang .xiaoxi.kefu .paopao { background: #e8f0ff; color: #132d60; }
.visitor-link-chat .fangke-chuang .paopao small { color: var(--chat-muted); }
.visitor-link-chat .fangke-chuang .touxiang2 { border-radius: 50%; }

.visitor-link-chat .fangke-chuang > footer {
  flex: 0 0 auto;
  padding: 8px 15px max(10px, env(safe-area-inset-bottom));
  border: 0;
  background: var(--chat-surface);
}

.visitor-link-chat .fangke-chuang > footer > .fangke-editor,
.visitor-link-chat .fangke-chuang[data-shuru] > footer > .fangke-editor {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "message send" "tools tools";
  align-items: end;
  column-gap: 8px;
  padding: 7px;
  border: 1px solid var(--chat-line);
  border-radius: 15px;
  background: var(--chat-surface);
}

.visitor-link-chat .fangke-chuang .fangke-editor:focus-within {
  border-color: var(--chat-accent);
  box-shadow: 0 0 0 2px #2563eb35;
}
.visitor-link-chat .fangke-editor #fangke-shuru {
  grid-area: message;
  box-sizing: border-box;
  min-width: 0;
  width: 100%;
  height: auto;
  min-height: 44px;
  max-height: 108px;
  padding: 9px 7px;
  field-sizing: content;
  background: var(--chat-surface);
  color: var(--chat-ink);
  font-size: 16px;
  line-height: 1.5;
}
.visitor-link-chat .fangke-editor #fangke-shuru::placeholder { color: var(--chat-muted); opacity: 1; }
.visitor-link-chat .fangke-editor #fangke-shuru:focus-visible { outline: none !important; box-shadow: none; }

.visitor-link-chat .fangke-gongju {
  grid-area: tools;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
}
.visitor-link-chat .fangke-gongju:not(:has(> :is(button, a, label):not([hidden]))) { display: none; }
.visitor-link-chat .fangke-editor > .fangke-biaoqing-mianban:not([hidden]) {
  bottom: calc(100% + 6px);
  max-height: min(200px, 35dvh);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  overflow-y: auto;
}
.visitor-link-chat .fangke-editor .fangke-biaoqing-mianban button {
  width: 100%;
  min-height: 40px;
  padding: 0;
  border-radius: 7px;
  background: transparent;
  font-size: 20px;
  line-height: 1;
}
.visitor-link-chat .fangke-editor .fangke-biaoqing-mianban button:hover { background: var(--chat-soft); }

.visitor-link-chat .fangke-gongju label,
.visitor-link-chat .fangke-gongju button,
.visitor-link-chat .fangke-gongju a {
  position: relative;
  display: grid;
  place-items: center;
  align-self: center;
  box-sizing: border-box;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--chat-muted);
}
.visitor-link-chat .fangke-gongju label { font-size: 0; }
.visitor-link-chat .fangke-gongju #fangke-wenjian {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  clip-path: inset(50%);
}
.visitor-link-chat .fangke-gongju label:focus-within { outline: 2px solid var(--chat-accent); }

.visitor-link-chat #fangke-fasong {
  grid-area: send;
  display: grid;
  place-items: center;
  align-self: end;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
  background: var(--chat-accent);
  color: #fff;
  font-size: 0;
  cursor: pointer;
}
.visitor-link-chat #fangke-fasong:enabled:hover { background: #174cc3; }
.visitor-link-chat #fangke-fasong:disabled { background: #eceef1; color: #747e8d; cursor: default; }
.visitor-link-chat .fangke-storage-note {
  display: block;
  margin-top: 6px;
  color: var(--chat-muted);
  font-size: 11px;
  text-align: center;
}

.visitor-link-chat .fangke-fenliu { inset: 65px 0 0; }
.visitor-link-chat .fangke-chuang [hidden] { display: none; }

.visitor-link-chat .fangke-chuang.fangke-fullscreen {
  width: 100%;
  height: 100dvh;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

body.visitor-link-chat.shouqi .fangke-chuang { height: auto; }
.visitor-link-chat.shouqi .fangke-chuang > :not(header) { display: none; }

@media (max-width: 700px) {
  .visitor-link-chat .fangke-chuang {
    width: 100%;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .visitor-link-chat .fangke-welcome { width: min(88%, 330px); }
}

.fangke-chuang :is(.fangke-gongju, .fangke-footer-meta) #fangke-jieshu {
  width: auto;
  height: auto;
  min-height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #52637a;
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}
.fangke-chuang #fangke-jieshu[hidden] { display: none; }
.fangke-chuang #fangke-jieshu:hover { background: #edf2f8; color: #244d92; }
.fangke-footer-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 0; }
.visitor-link-chat .fangke-footer-meta .fangke-storage-note { margin-top: 0; text-align: start; }
@media (max-width: 700px) {
  .fangke-chuang :is(.fangke-gongju, .fangke-footer-meta) #fangke-jieshu { min-height: 44px; }
}

#fangke-jieshu-dialog {
  box-sizing: border-box;
  width: min(360px, calc(100% - 32px));
  padding: 20px;
  border: 1px solid #dce5ef;
  border-radius: 14px;
  background: #fff;
  color: #18202d;
}
#fangke-jieshu-dialog::backdrop { background: #18202d66; }
#fangke-jieshu-dialog h2 { margin: 0 0 10px; font-size: 17px; }
#fangke-jieshu-dialog p { margin: 0 0 14px; color: #52637a; font-size: 14px; line-height: 1.55; }
#fangke-jieshu-dialog .fangke-jieshu-error { color: #a12722; }
#fangke-jieshu-dialog .fangke-jieshu-error:empty { margin: 0; }
.fangke-jieshu-actions { display: flex; justify-content: flex-end; gap: 8px; }
.fangke-jieshu-actions button {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #dce5ef;
  border-radius: 8px;
  background: #fff;
  color: #18202d;
  cursor: pointer;
}
.fangke-jieshu-actions button[value="end"] { border-color: #ad322c; background: #ad322c; color: #fff; }
.fangke-jieshu-actions button:disabled { opacity: .6; cursor: wait; }
