/* 客服反馈（专员端）。默认亮色，body[theme-mode="dark"] 暗色。 */
.kefu-fb-page {
  --fb-bg: #f5f6f8; --fb-surface: #fff; --fb-line: #e5e6eb; --fb-line-soft: #f0f0f2;
  --fb-text: #1d2129; --fb-text-2: #86909c; --fb-shadow: 0 1px 2px rgba(0,0,0,.04);
  position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column;
  background: var(--fb-bg); color: var(--fb-text);
  font-family: "PingFang SC","Noto Sans SC","Microsoft YaHei",sans-serif;
  -webkit-font-smoothing: antialiased;
}
body[theme-mode='dark'] .kefu-fb-page {
  --fb-bg: #0c0c0e; --fb-surface: #16161a; --fb-line: #2a2a31; --fb-line-soft: #202027;
  --fb-text: #ececec; --fb-text-2: #8d8d93; --fb-shadow: none;
}
.kefu-fb-bar { flex: none; display: flex; align-items: baseline; gap: 10px; padding: 14px 16px 12px;
  background: var(--fb-surface); border-bottom: 1px solid var(--fb-line); }
.kefu-fb-back { width: 26px; height: 26px; align-self: center; border: 0; border-radius: 5px;
  background: transparent; color: var(--fb-text-2); font-size: 17px; line-height: 1; cursor: pointer; }
.kefu-fb-title { font-size: 16px; font-weight: 600; }
.kefu-fb-sub { margin-left: auto; align-self: center; font-size: 11px; color: var(--fb-text-2); }
.kefu-fb-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 14px 24px; }
.kefu-fb-empty { padding: 40px 20px; text-align: center; color: var(--fb-text-2); font-size: 13px; }
.kefu-fb-sec { margin: 6px 0 10px; font-size: 12px; font-weight: 600; letter-spacing: .06em; color: var(--fb-text-2); }
.kefu-fb-sec:not(:first-child) { margin-top: 22px; }
.kefu-fb-blocks { display: flex; flex-direction: column; gap: 10px; }
.kefu-fb-block { display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: var(--fb-surface); border: 1px solid var(--fb-line); border-radius: 8px;
  box-shadow: var(--fb-shadow); cursor: pointer; transition: border-color .15s; }
.kefu-fb-block:hover { border-color: #2d8cf0; }
.kefu-fb-block-icon { flex: none; width: 30px; height: 30px; }
.kefu-fb-block-icon svg { width: 100%; height: 100%; fill: currentColor; }
.kefu-fb-block-txt { flex: 1; min-width: 0; }
.kefu-fb-block-txt b { display: block; font-size: 15px; font-weight: 600; }
.kefu-fb-block-txt span { display: block; margin-top: 3px; font-size: 12px; color: var(--fb-text-2); }
.kefu-fb-block-arrow { flex: none; color: #c9cdd4; font-size: 18px; font-style: normal; }
.kefu-fb-item { padding: 12px 14px; background: var(--fb-surface); border: 1px solid var(--fb-line);
  border-radius: 8px; margin-bottom: 8px; }
.kefu-fb-item-hd { display: flex; align-items: center; gap: 8px; }
.kefu-fb-item-hd b { flex: 1; min-width: 0; font-size: 14px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kefu-fb-item-hd em { flex: none; font-style: normal; font-size: 11px; font-weight: 600;
  padding: 1px 8px; border-radius: 3px; }
.kefu-fb-item-hd em.todo { background: #fff3d6; color: #b8860b; }
.kefu-fb-item-hd em.doing { background: #e8f3ff; color: #2d8cf0; }
.kefu-fb-item-hd em.done { background: #e8f7ee; color: #18a058; }
.kefu-fb-item-hd em.closed { background: #f2f3f5; color: #86909c; }
body[theme-mode='dark'] .kefu-fb-item-hd em.todo { background: rgba(184,134,11,.18); color: #e0b654; }
body[theme-mode='dark'] .kefu-fb-item-hd em.doing { background: rgba(45,140,240,.18); color: #6aa9f0; }
body[theme-mode='dark'] .kefu-fb-item-hd em.done { background: rgba(24,160,88,.18); color: #4ec98a; }
body[theme-mode='dark'] .kefu-fb-item-hd em.closed { background: #22222a; color: #8d8d93; }
.kefu-fb-item-meta { margin-top: 5px; font-size: 11px; color: var(--fb-text-2); }
.kefu-fb-item-reply { margin-top: 9px; padding: 9px 11px; background: var(--fb-line-soft);
  border-radius: 6px; font-size: 13px; line-height: 1.6; }
.kefu-fb-item-reply span { display: block; margin-bottom: 3px; font-size: 11px; font-weight: 600; color: #2d8cf0; }
.kefu-fb-form { background: var(--fb-surface); border: 1px solid var(--fb-line);
  border-radius: 8px; box-shadow: var(--fb-shadow); padding: 16px; }
.kefu-fb-form-hd { display: flex; align-items: center; gap: 9px; padding-bottom: 12px;
  margin-bottom: 14px; border-bottom: 2px solid var(--fb-line); }
.kefu-fb-form-hd span { flex: none; width: 22px; height: 22px; }
.kefu-fb-form-hd svg { width: 100%; height: 100%; fill: currentColor; }
.kefu-fb-form-hd b { font-size: 15px; font-weight: 600; }
.kefu-fb-form-hd em { font-style: normal; font-size: 12px; color: var(--fb-text-2); }
.kefu-fb-field { display: block; margin-bottom: 14px; }
.kefu-fb-field > span { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; }
.kefu-fb-field input, .kefu-fb-field textarea { display: block; width: 100%; box-sizing: border-box;
  padding: 10px 12px; font-size: 14px; font-family: inherit; color: var(--fb-text);
  background: var(--fb-bg); border: 1px solid var(--fb-line); border-radius: 6px;
  outline: none; transition: border-color .15s; }
.kefu-fb-field input:focus, .kefu-fb-field textarea:focus { border-color: #2d8cf0; }
.kefu-fb-field textarea { resize: vertical; line-height: 1.6; }
.kefu-fb-acts { display: flex; gap: 10px; margin-top: 4px; }
.kefu-fb-btn { flex: 1; height: 42px; border-radius: 6px; cursor: pointer; font-size: 15px;
  font-weight: 600; font-family: inherit; border: 1px solid var(--fb-line);
  background: transparent; color: var(--fb-text); }
.kefu-fb-btn.primary { background: #2d8cf0; border-color: #2d8cf0; color: #fff; }
.kefu-fb-btn.ghost { flex: 0 0 96px; color: var(--fb-text-2); }
@media screen and (max-width: 640px) {
  .kefu-fb-page { bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
  .kefu-fb-bar { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  .kefu-fb-body { padding: 12px 10px 20px; }
  #kefu-fb-rail svg { width: 24px; height: 24px; fill: currentColor; }
}

/* —— 反馈附件 —— */
.kefu-fb-field { display: block; margin-bottom: 14px; }
.kefu-fb-field > span { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; }
.kefu-fb-media {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.kefu-fb-tile {
  position: relative;
  flex: 0 0 76px;
  width: 76px;
  height: 76px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--fb-line-soft);
  border: 1px solid var(--fb-line);
}
.kefu-fb-tile img,
.kefu-fb-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.kefu-fb-tile.uploading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .42);
}
.kefu-fb-tile-load {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  text-align: center;
  color: #fff;
  font-size: 11px;
  z-index: 2;
}
.kefu-fb-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-style: normal;
  font-size: 11px;
  line-height: 26px;
  text-align: center;
  pointer-events: none;
}
.kefu-fb-tile-del {
  position: absolute;
  right: 3px;
  top: 3px;
  z-index: 3;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.kefu-fb-add {
  position: relative;
  flex: 0 0 76px;
  width: 76px;
  height: 76px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px dashed var(--fb-line);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  color: var(--fb-text-2);
  transition: border-color .15s, color .15s;
}
.kefu-fb-add:hover { border-color: #2d8cf0; color: #2d8cf0; }
.kefu-fb-add i { font-style: normal; font-size: 20px; line-height: 1; }
.kefu-fb-add em { font-style: normal; font-size: 11px; }
/* 原生 file 控件必须彻底藏掉：宿主页面的 input 全局样式会压过 [hidden] 的 UA 规则，
   否则「选择文件 未选择任何文件」会直接漏在表单里 */
.kefu-fb-add input[type='file'] {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  pointer-events: none;
}
.kefu-fb-hint { margin-top: 7px; font-size: 11px; color: var(--fb-text-2); }

/* 我的反馈里的附件 */
.kefu-fb-item-media {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 9px;
}
.kefu-fb-item-media img,
.kefu-fb-item-media video {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 5px;
  background: var(--fb-line-soft);
  display: block;
}
.kefu-fb-item-media img { cursor: zoom-in; }

/* 点击放大 */
.kefu-fb-viewer {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .92);
  padding: 20px;
}
.kefu-fb-viewer img,
.kefu-fb-viewer video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
}
.kefu-fb-viewer-close {
  position: absolute;
  right: 16px;
  top: calc(16px + env(safe-area-inset-top, 0px));
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

@media screen and (max-width: 640px) {
  .kefu-fb-media,
  .kefu-fb-item-media { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================================
 * 附件展示修正
 *
 * 两个问题：
 *  1. 视频没设 aspect-ratio，渲染时按原始尺寸铺开，一张视频能占半屏；
 *  2. 图片加载失败时留着破图图标，没有兜底。
 * 统一给图片与视频相同的容器比例，失败的直接收起。
 * ============================================================ */
.kefu-fb-item-media {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
}
.kefu-fb-item-media img,
.kefu-fb-item-media video {
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  max-height: 96px;
  object-fit: cover;
  border-radius: 5px;
  background: var(--fb-line-soft);
  display: block;
}
.kefu-fb-item-media video { background: #000; }

/* 加载失败：直接收起来，不留破图 */
.kefu-fb-item-media img.failed,
.kefu-fb-item-media video.failed,
.kefu-fb-tile img.failed,
.kefu-fb-tile video.failed {
  display: none;
}

/* 无附件 */
.kefu-fb-item-noattach {
  margin-top: 8px;
  color: var(--fb-text-3, #c9cdd4);
  font-size: 12px;
}
.kefu-fb-item-media:empty { display: none; }

@media screen and (max-width: 640px) {
  .kefu-fb-item-media { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kefu-fb-item-media img,
  .kefu-fb-item-media video { max-height: 88px; }
}

/* —— 撤回反馈 —— */
.kefu-fb-wd-wrap { display: flex; justify-content: flex-end; align-items: center; margin-top: 9px; }
.kefu-fb-wd { padding: 4px 13px; border: 1px solid var(--fb-line); border-radius: 5px;
  background: transparent; color: var(--fb-text-2); font-size: 12px;
  font-family: inherit; cursor: pointer; transition: color .15s, border-color .15s; }
.kefu-fb-wd:hover { color: #f53f3f; border-color: #f53f3f; }
.kefu-fb-confirm { display: none; align-items: center; gap: 8px; }
.kefu-fb-wd-wrap.confirming .kefu-fb-wd { display: none; }
.kefu-fb-wd-wrap.confirming .kefu-fb-confirm { display: flex; }
.kefu-fb-confirm > span { color: var(--fb-text-2); font-size: 12px; }
.kefu-fb-confirm button { padding: 4px 12px; border-radius: 5px; font-size: 12px;
  font-family: inherit; cursor: pointer; }
.kefu-fb-confirm-no { border: 1px solid var(--fb-line); background: transparent; color: var(--fb-text-2); }
.kefu-fb-confirm-yes { border: 1px solid #f53f3f; background: #f53f3f; color: #fff; }
