@import url("/tokens.css?v=20260913dark1");

/* 颜色与字体来自 tokens.css，这里只留移动端安全区与坐席布局 */
:root {
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); }
.hidden { display: none !important; }
.muted, .hint { color: var(--muted); font-size: 13px; }
.btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  padding: 8px 12px; font: inherit; cursor: pointer;
  white-space: nowrap; color: var(--ink); text-decoration: none;
}
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.ghost { background: transparent; }
a.btn { display: inline-flex; align-items: center; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.theme-toggle { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.theme-toggle-icon { width: 16px; height: 16px; display: block; fill: currentColor; stroke: currentColor; stroke-width: 1.7; pointer-events: none; }
.theme-toggle-icon.is-sun { fill: none; }
.theme-toggle .theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .theme-icon-sun { display: block; }
.gate { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: min(400px, 100%); background: var(--panel); border-radius: 16px;
  padding: 28px 22px; display: grid; gap: 8px;
}
.login-card img { width: 56px; height: 56px; border-radius: 14px; }
.login-card h1 { margin: 8px 0 0; font-size: 22px; }
.login-card input, .filters select, .filters input, .cus-profile input,
.cus-profile select, .cus-profile textarea, .follow-form select,
.follow-form input, .follow-form textarea, .top select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit;
  background: var(--input); color: var(--ink);
}
.msg { color: var(--danger-ink); min-height: 1.2em; }
.shell {
  min-height: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-t);
  padding-bottom: calc(56px + var(--safe-b));
  background: var(--panel);
}
.shell > .pane {
  flex: 1;
  min-height: 0;
}
.top {
  flex-shrink: 0;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.top > div:first-child { min-width: 0; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.top select { width: auto; padding: 6px 8px; }
.pane { overflow: auto; padding: 10px 12px 16px; min-height: 0; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.filters input[type="search"] { grid-column: 1 / -1; }
.list { display: grid; gap: 8px; }
.card {
  display: block; width: 100%; text-align: left; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; font: inherit; cursor: pointer;
}
.card strong { display: inline-block; margin-right: 6px; }
.card .muted {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-top: 4px;
}
.badge { font-size: 12px; padding: 2px 6px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); }
.badge.warn { background: var(--warn-mid); color: var(--warn); }
.badge.off { background: var(--msg); color: var(--muted); }
.badge.danger { background: var(--danger-soft); color: var(--danger-ink); }
.card.needs-accept {
  border-color: #fdba74;
  background: var(--warn-mid);
  box-shadow: inset 3px 0 0 #ea580c;
}
.card.needs-accept strong { color: var(--warn); }
.card.needs-accept .badge.warn {
  background: #ea580c;
  color: #fff;
}
.inbox-alert {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ea580c;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  animation: desk-queue-pulse 1.6s ease-in-out infinite;
}
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }

/* 会话详情：消息区占满剩余高度，输入条贴底 */
#pane-thread {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  overflow: hidden;
  padding: 0;
  background: var(--bg);
}
.thread-bar {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.thread-who {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.thread-who strong {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 15px; line-height: 1.3;
}
.thread-who .muted {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px;
}
.thread-who .muted:empty { display: none; }
.thread-ops { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.thread-ops .btn { padding: 6px 10px; font-size: 13px; }

.thread-context {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.visitor-card {
  padding: 8px 12px 6px;
  font-size: 13px;
}
.visitor-card:empty { display: none; }
.vcard-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.vcard-head strong { font-size: 14px; }
.vcard-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.vcard-facts span,
.vcard-facts a,
.vcard-facts button {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--ink);
  text-decoration: none;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vcard-facts button {
  font: inherit;
  cursor: pointer;
  background: var(--brand-soft);
  border-color: var(--brand-line);
  color: var(--brand);
}
.contact-chip { padding: 0 12px 8px; }
.contact-chip .btn {
  width: auto;
  display: inline-flex;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 999px;
  color: var(--brand);
  border-color: var(--brand-line);
  background: var(--brand-soft);
}

.msgs {
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overscroll-behavior: contain;
  background: var(--bg);
}
.msgs::before { content: ''; flex: 1 0 8px; }
.bubble {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.5;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.bubble.visitor { align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.agent { align-self: flex-end; background: var(--brand-soft); border-color: var(--brand-line); border-bottom-right-radius: 4px; }
.bubble.bot { align-self: flex-end; background: var(--msg-bot); border-color: var(--msg-bot-line); border-bottom-right-radius: 4px; }
.bubble.system, .bubble.note {
  align-self: center;
  max-width: 92%;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 4px 8px;
}
.bubble.note { background: var(--warn-mid); border: 1px solid var(--warn-line); color: var(--warn-ink); }
.bubble span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.bubble time { font-style: normal; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bubble.system span, .bubble.note span { display: none; }
.desk-img img { max-width: min(200px, 70vw); border-radius: 8px; display: block; }

.kb-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px 0; background: var(--panel); }
.kb-suggest:empty { display: none; }
.kb-suggest .chip {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 4px 10px; font: inherit; font-size: 12px;
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px 10px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.composer-tools {
  display: flex;
  gap: 6px;
  align-items: center;
}
.composer-tools select {
  flex: 1;
  min-width: 0;
  width: auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: var(--panel);
}
.composer-tools .btn { padding: 8px 10px; }
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin: 8px 0 12px;
}
.emoji-grid button {
  border: 0;
  border-radius: 8px;
  background: var(--bg);
  min-width: 38px;
  height: 38px;
  font-size: 21px;
}
.composer-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.composer-row textarea {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 120px;
  width: auto;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  resize: none;
  line-height: 1.45;
}
.composer-row .btn.primary {
  align-self: stretch;
  min-height: 44px;
  padding: 10px 16px;
}

.work-form { display: grid; gap: 8px; padding: 10px 12px 24px; }
.work-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.work-form input, .work-form select, .work-form textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; color: var(--ink);
}
.cus-profile, .follow-form { display: grid; gap: 8px; padding: 10px 12px; }
.cus-profile label, .follow-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
#cusPhone[readonly] { background: var(--bg); color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.follows { padding: 0 12px 16px; display: grid; gap: 8px; }
.follow { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.pane h3 { margin: 12px 12px 4px; font-size: 14px; }
#pane-customer, #pane-work-detail { padding: 0; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  background: var(--panel); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
  z-index: 10;
}
.tab {
  border: 0; background: none; padding: 12px; font: inherit; color: var(--muted);
}
.tab.is-on { color: var(--brand); font-weight: 600; }
.tab-badge {
  display: inline-block;
  min-width: 16px;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ea580c;
  color: #fff;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  line-height: 16px;
  vertical-align: middle;
}
.tab-badge.is-zero { display: none; }
@keyframes desk-queue-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(234, 88, 12, .28); }
  50% { box-shadow: 0 0 0 4px rgba(234, 88, 12, .12); }
}
@media (prefers-reduced-motion: reduce) {
  .inbox-alert { animation: none; }
}
.toast {
  position: fixed; left: 50%; bottom: calc(72px + var(--safe-b)); transform: translateX(-50%);
  background: #111827; color: #fff; padding: 8px 14px; border-radius: 999px; z-index: 20;
}
.toast.err { background: #b91c1c; }
.sheet-wrap { position: fixed; inset: 0; z-index: 30; }
.sheet-mask { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--panel); border-radius: 14px 14px 0 0;
  padding: 14px 14px calc(14px + var(--safe-b));
  display: grid; gap: 10px; max-height: 72%; overflow: auto;
}
.sheet h3 { margin: 0; font-size: 15px; }
.xfer-groups { display: flex; flex-wrap: wrap; gap: 6px; }
.xfer-chip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
}
.xfer-chip.is-on {
  background: var(--brand-soft);
  border-color: var(--brand-line);
  color: var(--brand);
  font-weight: 600;
}
.sheet label.row { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.sheet label.row { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.sheet input, .sheet select, .sheet textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; box-sizing: border-box; font: inherit; background: var(--panel);
}
.tag-edit { margin-left: 4px; padding: 0 6px; font-size: 12px; border: 0; color: var(--brand); }
.login-card .pc-hint {
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 13px;
}
.login-card .pc-hint a { color: inherit; font-weight: 600; }

@media (max-width: 420px) {
  #pane-thread .thread-ops #btnToWork { display: none; }
}

/* 电脑浏览器打开手机值班台时，收成手机宽度，避免会话区被拉散 */
@media (min-width: 720px) {
  body { background: #d7dee6; }
  .shell {
    max-width: 480px;
    margin: 0 auto;
    box-shadow: var(--shadow-lg);
  }
  .tabbar,
  .sheet-wrap {
    max-width: 480px;
    left: 50%;
    right: auto;
    width: 100%;
    transform: translateX(-50%);
  }
  .sheet-wrap { transform: translateX(-50%); }
}

.desk-voice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
  padding: 8px 12px;
  border-radius: 16px;
  background: rgba(15, 118, 110, .12);
  cursor: pointer;
}
.desk-voice-play {
  border: 0;
  background: #0f766e;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 11px;
  padding: 0;
}
.desk-voice-bar {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: repeating-linear-gradient(-45deg, #99f6e4, #99f6e4 3px, #5eead4 3px, #5eead4 6px);
}
.desk-voice-dur { font-variant-numeric: tabular-nums; font-size: 13px; }
.desk-voice-rec {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.desk-voice-rec.hidden { display: none; }
.desk-voice-rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #dc2626;
}
.desk-voice-hint {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}
