/* 客服浮窗 iframe 样式: 独立于主站 (不加载 Tailwind / Next.js), 色值对齐主站中性灰白 token。 */
:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #737373;
  --border: #e5e5e5;
  --surface: #f5f5f5;
  --bubble-self: #171717;
  --bubble-self-fg: #fafafa;
  --danger: #dc2626;
  --ring: #2EA7E0;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --fg: #fafafa;
    --muted: #a3a3a3;
    --border: #262626;
    --surface: #171717;
    --bubble-self: #fafafa;
    --bubble-self-fg: #0a0a0a;
    --danger: #f87171;
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.55 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }

.app { display: flex; flex-direction: column; height: 100%; }

.head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 14px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.logo { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.logo-fallback { background: var(--surface); display: flex; align-items: center; justify-content: center; font-weight: 600; }
.head-text { flex: 1; min-width: 0; }
.title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subtitle { font-size: 12px; color: var(--muted); }
.icon-btn { background: none; border: 0; color: var(--muted); width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--surface); color: var(--fg); }

.body { flex: 1; min-height: 0; overflow-y: auto; position: relative; }

.loading { display: flex; gap: 6px; justify-content: center; padding: 48px 0; }
.loading span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.loading span:nth-child(2) { animation-delay: .2s; }
.loading span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.messages { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.day { align-self: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.msg { display: flex; flex-direction: column; max-width: 82%; }
.msg.self { align-self: flex-end; align-items: flex-end; }
.msg.other { align-self: flex-start; align-items: flex-start; }
.msg.system { align-self: center; max-width: 90%; }
.bubble { padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; }
.self .bubble { background: var(--bubble-self); color: var(--bubble-self-fg); border-bottom-right-radius: 4px; }
.other .bubble { background: var(--surface); border-bottom-left-radius: 4px; }
.system .bubble { background: none; color: var(--muted); font-size: 12px; text-align: center; padding: 0; }
.meta { font-size: 11px; color: var(--muted); margin-top: 3px; padding: 0 4px; }
.msg.pending .bubble { opacity: .6; }
.msg.failed .meta { color: var(--danger); }
.bubble a { color: inherit; text-decoration: underline; }

.form { display: flex; flex-direction: column; gap: 12px; padding: 20px 16px; }
.form-title { font-size: 16px; font-weight: 600; }
.form-desc { color: var(--muted); font-size: 13px; margin-top: -6px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.field span { color: var(--muted); }
.field.required span::after { content: " *"; color: var(--danger); }
.field input, .field textarea, .composer textarea {
  width: 100%; font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; resize: none;
}
.primary { background: var(--bubble-self); color: var(--bubble-self-fg); border: 0; border-radius: 8px; padding: 10px; font-weight: 600; }
.primary:disabled { opacity: .5; cursor: default; }
.error { color: var(--danger); font-size: 12px; min-height: 0; }
.error:empty { display: none; }

.notice { margin: 24px 16px; padding: 14px; border-radius: 10px; background: var(--surface); color: var(--muted); text-align: center; }

.composer { border-top: 1px solid var(--border); padding: 10px 12px; flex-shrink: 0; }
.composer .error { padding-bottom: 6px; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; max-height: 120px; line-height: 1.45; }
.send { width: 38px; height: 38px; border-radius: 8px; border: 0; background: var(--bubble-self); color: var(--bubble-self-fg); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.send:disabled { opacity: .4; cursor: default; }

.powered { display: block; text-align: center; font-size: 11px; color: var(--muted); padding: 6px 0 8px; text-decoration: none; flex-shrink: 0; }
.powered:hover { color: var(--fg); }

.attach { width: 38px; height: 38px; flex-shrink: 0; }
.bubble.media { padding: 4px; background: none; }
.bubble.media img { display: block; max-width: 220px; max-height: 220px; border-radius: 10px; cursor: zoom-in; }
.file-link { display: inline-flex; align-items: center; gap: 6px; color: inherit; text-decoration: none; cursor: pointer; }
.file-link:hover span { text-decoration: underline; }
.file-size { opacity: .7; font-size: 12px; }
.field.verified input { background: var(--surface); color: var(--muted); }
.field.verified span::after { content: " · 已校验"; color: var(--muted); }

.app { position: relative; }

.start, .contact-view { display: flex; flex-direction: column; gap: 10px; padding: 20px 16px; }
.start-title { font-size: 16px; font-weight: 600; }
.contacts { display: flex; flex-direction: column; gap: 8px; }
.contact-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--fg); text-align: left; }
.contact-btn:hover { background: var(--surface); }
.contact-btn em { font-style: normal; font-size: 12px; color: var(--muted); }
.back { align-self: flex-start; display: inline-flex; align-items: center; gap: 2px; background: none; border: 0; color: var(--muted); padding: 2px 0; }
.back:hover { color: var(--fg); }
.contact-view img { width: 100%; max-width: 280px; align-self: center; border-radius: 10px; border: 1px solid var(--border); }
.contact-tip { text-align: center; color: var(--muted); font-size: 12px; }

.confirm { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 5; }
.confirm-box { background: var(--bg); border-radius: 12px; padding: 16px; width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 10px; }
.confirm-box img { max-width: 100%; max-height: 240px; object-fit: contain; border-radius: 8px; align-self: center; }
.confirm-name { font-size: 13px; color: var(--muted); word-break: break-all; }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }
.confirm-actions button { padding: 8px 14px; }
.ghost { background: none; border: 1px solid var(--border); border-radius: 8px; color: var(--fg); }

.drop { position: absolute; inset: 8px; border: 2px dashed var(--border); border-radius: 12px; background: var(--bg); color: var(--muted); display: flex; align-items: center; justify-content: center; z-index: 4; pointer-events: none; opacity: .95; }
