@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Noto+Sans+SC:wght@400;500;700&display=swap");

:root {
  --bg: #f4f6f8;
  --bg2: #ffffff;
  --panel: #ffffff;
  --panel2: #f0f2f5;
  --line: #d8dee6;
  --line2: #e8ecf1;
  --text: #0b0d10;
  --muted: #5c6672;
  --accent: #111827;
  --accent2: #374151;
  --ink: #000000;
  --danger: #dc2626;
  --ok: #059669;
  --warn: #b45309;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
  --font: "Space Grotesk", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "Space Grotesk", ui-monospace, Consolas, monospace;
  --sidebar-w: 232px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
html, body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--text); font-family: var(--font);
}
body {
  background:
    linear-gradient(180deg, #ffffff 0%, #f4f6f8 42%, #eef1f5 100%);
  background-attachment: fixed;
}
a { color: var(--ink); text-decoration: none; border-bottom: 1px solid #cbd5e1; }
a:hover { border-bottom-color: #000; }

button, input, select, textarea {
  font: inherit; color: inherit; border-radius: 8px;
  border: 1px solid var(--line); background: #fff;
  padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
button {
  cursor: pointer; background: var(--ink); border-color: var(--ink);
  color: #fff; font-weight: 600; letter-spacing: .02em;
}
button:hover { background: #1f2937; }
button.secondary {
  background: #fff; border: 1px solid var(--line); color: var(--text);
}
button.secondary:hover { border-color: #9aa3af; background: #fafbfc; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button:disabled { opacity: .45; cursor: not-allowed; }
input:focus, select:focus, textarea:focus {
  border-color: #111827;
  box-shadow: 0 0 0 3px rgba(17, 24, 39, .08);
}
textarea { resize: vertical; min-height: 80px; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 20px 16px 48px; }
.nav {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.88); backdrop-filter: blur(12px);
}
.brand {
  font-size: 1.05rem; font-weight: 700; letter-spacing: -.02em;
  display: flex; align-items: center; gap: 8px;
}
.brand::before {
  content: ""; width: 10px; height: 10px; background: #000;
  box-shadow: 0 0 0 3px #e5e7eb;
}
.brand span { color: var(--muted); font-weight: 500; font-size: .85rem; }
.nav-links { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.nav-links button {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 8px 12px; font-weight: 500;
}
.nav-links button.active, .nav-links button:hover {
  color: var(--text); border-color: var(--line); background: #fff;
}

.hero {
  display: grid; grid-template-columns: 1.15fr .85fr; gap: 28px; align-items: center;
  padding: 40px 0 28px;
}
.hero h1 {
  font-size: clamp(1.75rem, 5vw, 2.75rem); margin: 0 0 12px;
  line-height: 1.15; letter-spacing: -.03em; font-weight: 700;
}
.hero p { color: var(--muted); margin: 0 0 22px; line-height: 1.75; max-width: 36em; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  position: relative;
}
.card::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 2px;
  background: linear-gradient(180deg, #000, transparent);
  opacity: .12; border-radius: 2px;
}
.card h3 {
  margin: 0 0 12px; font-size: 1rem; letter-spacing: -.01em;
  display: flex; align-items: center; gap: 8px;
}
.card h3::before {
  content: ""; width: 6px; height: 6px; background: #000; flex-shrink: 0;
}

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat {
  padding: 16px; border-radius: var(--radius);
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow);
}
.stat .n {
  font-size: clamp(1.4rem, 3vw, 1.85rem); font-weight: 700;
  letter-spacing: -.03em; color: #000; font-variant-numeric: tabular-nums;
}
.stat .l { color: var(--muted); font-size: .82rem; margin-top: 6px; letter-spacing: .04em; text-transform: uppercase; }

.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 560px; }
.table th, .table td {
  padding: 11px 10px; border-bottom: 1px solid var(--line2);
  text-align: left; vertical-align: top;
}
.table th {
  color: var(--muted); font-weight: 600; font-size: .78rem;
  letter-spacing: .06em; text-transform: uppercase; white-space: nowrap;
}
.table tr:hover td { background: #fafbfc; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { color: var(--muted); font-size: .8rem; font-weight: 500; letter-spacing: .02em; }
.muted { color: var(--muted); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.danger { color: var(--danger); }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: .72rem;
  background: #f3f4f6; color: #111; border: 1px solid var(--line); font-weight: 600;
}
.code {
  font-family: var(--mono); font-size: .82rem; word-break: break-all;
  background: #f8fafc; padding: 2px 6px; border-radius: 4px; border: 1px solid var(--line2);
}
.price { color: #000; font-weight: 700; }
.footer { text-align: center; color: var(--muted); padding: 36px 0 16px; font-size: .8rem; }

/* Chat */
.chat-layout {
  display: grid; grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) minmax(200px, 240px);
  gap: 12px; min-height: calc(100vh - 200px);
}
.chat-crm {
  border: 1px solid var(--line); border-radius: 8px; padding: 12px;
  background: #fafbfc; overflow: auto; min-height: 480px; height: calc(100vh - 220px); max-height: none; font-size: .88rem;
}
.warn-banner {
  border-color: #f59e0b; background: #fffbeb; color: #92400e;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.nav-badge {
  display: inline-block; min-width: 18px; padding: 1px 6px; margin-left: 4px;
  background: #dc2626; color: #fff; border-radius: 999px; font-size: .72rem; font-weight: 600;
  vertical-align: middle;
}
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 960px) {
  .grid-3 { grid-template-columns: 1fr; }
}
.conv-list { overflow: auto; min-height: 480px; height: calc(100vh - 220px); max-height: none; border: 1px solid var(--line); border-radius: 8px; background: #fafbfc; }

/* cust-avatar */
.cust-avatar {
  position: relative; flex: 0 0 auto; border-radius: 50%; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  background: #e5e7eb; vertical-align: middle;
}
.cust-avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block; position: relative; z-index: 1;
}
.cust-avatar-letter {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px; letter-spacing: .02em;
}
.cust-avatar.is-fallback .cust-avatar-letter { position: static; width: 100%; height: 100%; }
.cust-avatar:not(.is-fallback) .cust-avatar-letter { display: none; }
.conv-item { display: flex; gap: 10px; align-items: flex-start; }
.conv-item-main { min-width: 0; flex: 1; }
.conv-item-top { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.conv-item-preview {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px;
}
.cust-headline { display: flex; gap: 10px; align-items: center; }
.mchat-item { display: flex; gap: 10px; align-items: flex-start; text-align: left; }
.mchat-item-main { min-width: 0; flex: 1; }
.mchat-title-wrap { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.mchat-title-wrap .mchat-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.conv-item {
  padding: 12px; border-bottom: 1px solid var(--line2); cursor: pointer;
  background: transparent; transition: background .12s;
}
.conv-item:hover { background: #f3f4f6; }
.conv-item.active { background: #111; color: #fff; }
.conv-item.active .muted { color: var(--muted); }
.conv-item.active .muted,
.conv-item.active .badge { color: #cbd5e1; border-color: #374151; background: #1f2937; }
.conv-item .star-mark { color: #ca8a04; margin-left: 2px; }
.conv-item.active .star-mark { color: #fbbf24; }
.conv-item.starred { border-left: 3px solid #ca8a04; }
.msg-box { display: flex; flex-direction: column; min-height: 520px; height: calc(100vh - 220px); }
.msgs {
  flex: 1; overflow: auto; padding: 14px;
  background:
    linear-gradient(90deg, rgba(0,0,0,.03) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(rgba(0,0,0,.03) 1px, transparent 1px) 0 0 / 24px 24px,
    #fff;
  border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px;
}
.bubble {
  max-width: min(85%, 420px); padding: 10px 12px; border-radius: 10px;
  margin: 8px 0; line-height: 1.55; white-space: pre-wrap;
  border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow);
}
.bubble.in { border-radius: 10px 10px 10px 2px; }
.bubble.out {
  margin-left: auto; background: #111; color: #fff; border-color: #111;
  border-radius: 10px 10px 2px 10px;
}
.bubble-time {
  margin-top: 6px; font-size: .68rem; opacity: .55; line-height: 1.2;
}
.bubble.out .bubble-time { color: #cbd5e1; opacity: .75; }

.toast {
  position: fixed; left: 50%; bottom: calc(18px + var(--safe-b));
  transform: translateX(-50%);
  background: #111; color: #fff; border: 1px solid #111;
  padding: 12px 18px; border-radius: 999px; z-index: 120;
  max-width: min(92vw, 420px); text-align: center; font-size: .9rem;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
}
.auth-box { max-width: 420px; margin: 48px auto 24px; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tabs button { flex: 1; }

/* Workbench layout */
.layout {
  display: grid; grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh; min-height: 100dvh;
}
.sidebar {
  background: #fff; border-right: 1px solid var(--line);
  padding: 14px 10px calc(20px + var(--safe-b));
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow: auto;
  z-index: 30;
}
.sidebar .brand { padding: 10px 12px 16px; }
.side-btn {
  display: block; width: 100%; text-align: left; margin: 2px 0; padding: 10px 12px;
  background: transparent; border: 1px solid transparent; color: var(--muted); font-weight: 500;
}
.side-btn.active, .side-btn:hover {
  background: #111; color: #fff; border-color: #111;
}
.side-sec {
  color: #9aa3af; font-size: .68rem; padding: 14px 12px 6px;
  letter-spacing: .12em; text-transform: uppercase; font-weight: 600;
}
.main { padding: 18px 18px calc(40px + var(--safe-b)); min-width: 0; background: transparent; }
.work-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; gap: 10px; flex-wrap: wrap;
}
.work-top h2 {
  margin: 0; font-size: clamp(1.15rem, 3vw, 1.45rem);
  letter-spacing: -.02em; font-weight: 700;
}

.bar-chart {
  display: flex; align-items: flex-end; gap: 4px; height: 120px;
  padding: 8px 0 22px; border-bottom: 1px solid var(--line2);
}
.bar-chart .bar {
  flex: 1; background: linear-gradient(180deg, #111 0%, #6b7280 100%);
  border-radius: 3px 3px 0 0; min-height: 2px; position: relative;
}
.bar-chart .bar span {
  position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%);
  font-size: .62rem; color: var(--muted); white-space: nowrap;
}

/* Mobile top bar + drawer */
.m-top {
  display: none; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94);
  position: sticky; top: 0; z-index: 40; backdrop-filter: blur(10px);
}
.m-top .menu-btn {
  width: 42px; height: 42px; padding: 0; display: inline-flex;
  align-items: center; justify-content: center; background: #fff;
  border: 1px solid var(--line); color: #111; border-radius: 8px;
}
.m-top .menu-btn span {
  display: block; width: 16px; height: 1.5px; background: #111; position: relative;
}
.m-top .menu-btn span::before, .m-top .menu-btn span::after {
  content: ""; position: absolute; left: 0; width: 16px; height: 1.5px; background: #111;
}
.m-top .menu-btn span::before { top: -5px; }
.m-top .menu-btn span::after { top: 5px; }
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 45;
}

@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; padding: 28px 0 20px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .layout { grid-template-columns: 1fr; }
  .m-top { display: flex; }
  .card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(86vw, 300px);
    transform: translateX(-105%); transition: transform .22s ease;
    box-shadow: 8px 0 32px rgba(0,0,0,.12); height: 100%; z-index: 50;
  }
  .layout.nav-open .sidebar { transform: translateX(0); }
  .layout.nav-open .sidebar-backdrop { display: block; }
  .side-sec { display: block; }
  .side-btn { width: 100%; }
  .main { padding: 14px 12px calc(28px + var(--safe-b)); }
  .chat-layout { grid-template-columns: 1fr; min-height: auto; }
  .chat-crm { max-height: none; order: -1; }
  .conv-list { max-height: 220px; }
  .msg-box { height: auto; min-height: 360px; }
  .msgs { min-height: 260px; }
  .auth-box { margin: 28px 12px; }
  .nav { padding: 10px 12px; }
  .nav-links button { padding: 7px 10px; font-size: .85rem; }
  .card { padding: 14px; }
  .work-top { margin-bottom: 12px; }
  .toast { bottom: calc(72px + var(--safe-b)); left: 12px; right: 12px; transform: none; max-width: none; border-radius: 12px; }
}

@media (max-width: 560px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .table { min-width: 480px; font-size: .84rem; }
  .bubble { max-width: 92%; }
  .row button, .row .secondary { flex: 1 1 auto; min-height: 42px; }
  .hero h1 { font-size: 1.65rem; }
  .stat .n { font-size: 1.45rem; }
  .bar-chart .bar span { font-size: .55rem; }
}

@media (min-width: 961px) {
  .m-top, .sidebar-backdrop { display: none !important; }
  .m-list { display: none !important; }
  .desk-only { display: block; }
}

/* Mobile card lists */
.m-list { display: none; flex-direction: column; gap: 10px; }
.desk-only { display: block; }
.m-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
.m-card-title { font-weight: 600; margin-bottom: 4px; }
.m-card-meta { color: var(--muted); font-size: .82rem; margin-bottom: 8px; }
.m-card-body { font-size: .92rem; line-height: 1.45; word-break: break-word; margin-bottom: 10px; }
.m-card-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.m-card-actions label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .88rem; }

.quick-bar {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0;
  border-top: 1px solid var(--line2); margin-top: 4px;
}
button.chip, .chip {
  background: #fff; border: 1px solid var(--line); color: var(--text);
  padding: 6px 10px; font-size: .82rem; font-weight: 500; border-radius: 999px;
}
button.chip:hover, .chip:hover { border-color: #111; background: #f8fafc; }
button.chip.active, .chip.active { background: #111; color: #fff; border-color: #111; }
.media-chip { display: inline-flex; align-items: center; gap: 6px; }
.media-chip img { width: 22px; height: 22px; object-fit: cover; border-radius: 4px; }
.msg-img { display: block; max-width: 240px; }
.msg-img img { max-width: 100%; max-height: 220px; border-radius: 8px; display: block; }
.thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; vertical-align: middle; margin-right: 8px; cursor: pointer; }
.thumb-lg { width: 100%; max-height: 160px; object-fit: cover; border-radius: 8px; margin-bottom: 8px; cursor: pointer; }

.chip-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px; margin: 2px 4px 2px 0;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: .82rem;
}
button.linkish, .linkish {
  background: none; border: none; color: #2563eb; padding: 0 2px;
  font-size: .78rem; font-weight: 500; cursor: pointer; text-decoration: underline;
}
button.linkish.danger-t, .danger-t { color: var(--danger); }

@media (max-width: 960px) {
  .desk-only { display: none !important; }
  .m-list { display: flex; margin-top: 10px; }
  .chat-layout.chat-focus .conv-list { display: none; }
  .chat-layout.chat-focus .msg-box { display: block; }
  .chat-back { display: inline-flex !important; }
}
.chat-back { display: none; }

/* guide-manual */
.guide-page .guide-hero h2 { margin: 0 0 8px; }
.guide-steps { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.guide-step-hd { display: flex; gap: 14px; align-items: flex-start; }
.guide-num {
  flex: 0 0 36px; height: 36px; border-radius: 50%;
  background: #111; color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}
.guide-fig { margin: 14px 0 8px; }
.guide-fig img {
  display: block; width: 100%; max-width: 920px; border-radius: 10px;
  border: 1px solid var(--line, #e5e7eb); cursor: zoom-in; background: #fff;
}
.guide-fig figcaption { margin-top: 6px; font-size: 12px; }
.guide-tip {
  margin: 0; padding: 10px 12px; border-radius: 8px;
  background: #f3f6fb; color: #334155; font-size: 13px; line-height: 1.55;
}
.guide-ol { margin: 8px 0 0 18px; line-height: 1.8; color: #334155; }
.guide-page .card h3 { margin-top: 0; }
.nav-guide-btn {
  padding: 8px 10px !important; font-size: .8rem !important; white-space: nowrap;
}
@media (max-width: 720px) {
  .guide-step-hd { gap: 10px; }
  .guide-num { flex-basis: 30px; height: 30px; font-size: 13px; }
}


/* mchat mobile reply (base layout) */
.mchat {
  position: fixed; inset: 0; z-index: 80;
  display: flex; flex-direction: column;
  background: var(--bg, #f4f6f8);
  height: 100dvh; max-height: 100dvh;
}
.mchat-hd {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top));
  background: #fff; border-bottom: 1px solid var(--line, #e5e7eb);
}
.mchat-list { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; }
.mchat-item {
  display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line,#e5e7eb);
  background: #fff; padding: 12px 14px; cursor: pointer;
}
.mchat-item-top { display: flex; align-items: center; gap: 8px; }
.mchat-preview { margin-top: 4px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mchat-badge {
  background: #ef4444; color: #fff; border-radius: 999px; font-size: 11px;
  min-width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
}
.mchat-focus .mchat-msgs {
  flex: 1; overflow: auto; -webkit-overflow-scrolling: touch;
  padding: 12px; display: flex; flex-direction: column; gap: 8px;
}
.mchat-bubble {
  max-width: 82%; padding: 8px 10px; border-radius: 12px; font-size: 14px; line-height: 1.45;
  word-break: break-word; background: #fff; border: 1px solid var(--line,#e5e7eb);
}
.mchat-bubble.out { align-self: flex-end; background: #111; color: #fff; border-color: #111; }
.mchat-bubble.in { align-self: flex-start; }
.mchat-bubble.out .mchat-time { color: rgba(255,255,255,.7); }
.mchat-time { font-size: 11px; margin-top: 4px; color: #94a3b8; }
.mchat-compose {
  flex: 0 0 auto; background: #fff; border-top: 1px solid var(--line,#e5e7eb);
  padding: 8px 10px; padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
.mchat-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.mchat-input-row { display: flex; gap: 8px; align-items: flex-end; }
.mchat-input-row textarea {
  flex: 1; min-height: 44px; max-height: 96px; resize: none;
  border: 1px solid var(--line,#e5e7eb); border-radius: 10px; padding: 8px 10px; font: inherit;
}
.mchat-send {
  flex: 0 0 auto; height: 44px; padding: 0 16px; border: 0; border-radius: 10px;
  background: #111; color: #fff; font-weight: 600;
}
body.page-mchat .sidebar,
body.page-mchat .work-top,
body.page-mchat .sidebar-backdrop,
body.page-mchat .m-top { display: none !important; }
body.page-mchat #app,
body.page-mchat .main,
body.page-mchat .wrap,
body.page-mchat .layout { padding: 0 !important; margin: 0 !important; max-width: none !important; }
body.page-mchat .layout { display: block !important; }
@media (min-width: 961px) {
  .mchat { max-width: 480px; margin: 0 auto; border-left: 1px solid var(--line,#e5e7eb); border-right: 1px solid var(--line,#e5e7eb); }
}
.media-upload-zone {
  border: 1.5px dashed var(--line,#cbd5e1); border-radius: 12px; padding: 16px;
  background: #f8fafc; text-align: center; margin-bottom: 12px;
}
.media-upload-zone strong { display: block; margin-bottom: 6px; }
.media-upload-zone .muted { font-size: 12px; margin-bottom: 10px; }
.media-preview {
  margin-top: 10px; max-width: 180px; max-height: 120px; border-radius: 8px;
  object-fit: cover; border: 1px solid var(--line,#e5e7eb);
}

/* mchat sheets + customer fab */
.mchat-title { display: inline-flex; align-items: center; gap: 6px; max-width: 58vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mchat-tag-ai {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; letter-spacing: .02em;
  padding: 1px 6px; border-radius: 999px; background: #0f172a; color: #fff; flex: 0 0 auto;
}
.mchat-cust-btn { position: relative; padding-right: 14px !important; }
.mchat-fab-badge {
  position: absolute; top: -6px; right: -4px; z-index: 2;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: #ef4444; color: #fff; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px #fff;
}
.mchat-ai-on { border-color: #0f172a !important; background: #0f172a !important; color: #fff !important; }
.mchat-sheet-mask {
  position: absolute; inset: 0; z-index: 90;
  background: rgba(15, 23, 42, .42);
  display: flex; align-items: flex-end; justify-content: center;
}
.mchat-sheet {
  width: 100%; max-height: min(78dvh, 640px);
  background: #fff; border-radius: 16px 16px 0 0;
  box-shadow: 0 -10px 40px rgba(0,0,0,.16);
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
  /* animation disabled: refresh remount flash */
  color: var(--text, #0b0d10);
  color: var(--text, #0b0d10);
}
@keyframes mchatSheetIn {
  from { transform: translateY(18px); opacity: .6; }
  to { transform: translateY(0); opacity: 1; }
}
.mchat-sheet-hd {
  flex: 0 0 auto; display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 14px 14px 10px; border-bottom: 1px solid var(--line, #e5e7eb);
}
.mchat-sheet-body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; }
.mchat-sheet-item {
  display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line,#e5e7eb);
  background: #fff; padding: 12px 14px; cursor: pointer;
}
.mchat-sheet-item.active { background: #f1f5f9; }
.mchat-sheet-item-top { display: flex; align-items: center; gap: 8px; }
.mchat-sheet-ai .mchat-sheet-body { padding: 10px 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.mchat-ai-row { display: flex; gap: 8px; align-items: stretch; }
.mchat-ai-main {
  flex: 1; text-align: left; border: 1px solid var(--line,#e5e7eb); border-radius: 12px;
  background: #fff; padding: 12px 12px; display: flex; flex-direction: column; gap: 4px; cursor: pointer;
}
.mchat-ai-main b { font-size: 15px; }
.mchat-ai-main .muted { font-size: 12px; }
.mchat-bang {
  flex: 0 0 42px; width: 42px; border-radius: 12px; border: 1px solid var(--line,#e5e7eb);
  background: #f8fafc; color: #0f172a; font-weight: 800; font-size: 16px; cursor: pointer;
}
.mchat-tip-box {
  margin: -2px 0 4px; padding: 10px 12px; border-radius: 10px;
  background: #f8fafc; border: 1px solid var(--line,#e5e7eb);
  font-size: 12px; line-height: 1.5; color: #475569;
}


.msg-media-tag {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px;
  border-radius: 999px; background: #e2e8f0; color: #0f172a; margin-right: 6px;
}
.msg-audio audio, .msg-video video { display: block; max-width: min(100%, 280px); margin-top: 6px; }
.msg-video video { border-radius: 8px; background: #000; }
.msg-file {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px;
  border-radius: 10px; background: #f1f5f9; color: inherit; text-decoration: none;
  word-break: break-all;
}
.mchat-bubble.out .msg-media-tag { background: rgba(255,255,255,.2); color: #fff; }
.mchat-bubble.out .msg-file { background: rgba(255,255,255,.12); color: #fff; }

.mchat { color: var(--text, #0b0d10); }
.mchat-hd, .mchat-hd b, .mchat-title { color: var(--text, #0b0d10); }
.mchat-sheet, .mchat-sheet-hd, .mchat-sheet-hd b { color: var(--text, #0b0d10); }
.mchat-sheet-item, .mchat-ai-main, .mchat-ai-main b { color: var(--text, #0b0d10); }
.mchat .muted, .mchat-sheet .muted { color: var(--muted, #5c6672) !important; background: transparent !important; border: 0 !important; }
.work-top h2, .card h3, .wrap h2 { color: var(--text, #0b0d10); }


/* commercial media bubbles */
.bubble-text { white-space: pre-wrap; word-break: break-word; }
.bubble-media { margin-top: 2px; }
.bubble-img-link { display: block; position: relative; max-width: min(100%, 240px); }
.bubble-img-link img {
  display: block; max-width: 100%; max-height: 280px; border-radius: 10px;
  background: #e2e8f0; object-fit: cover;
}
.bubble-img-link img.broken { display: none; }
.bubble-img-fallback {
  display: none !important; padding: 12px; border-radius: 10px; background: #f1f5f9;
  color: #0f172a; font-size: 13px; text-decoration: underline;
}
.bubble-img-fallback.is-visible,
.bubble-img-link img.broken + .bubble-img-fallback {
  display: block !important;
}
.bubble-img-link img.ok + .bubble-img-fallback {
  display: none !important;
}
.bubble-voice {
  display: inline-flex; align-items: center; gap: 8px; min-width: 128px; max-width: 220px;
  border: 0; border-radius: 18px; padding: 10px 14px; cursor: pointer;
  background: #f1f5f9; color: #0f172a; font: inherit;
}
.mchat-bubble.out .bubble-voice, .bubble.out .bubble-voice {
  background: rgba(255,255,255,.16); color: #fff;
}
.voice-icon {
  width: 18px; height: 18px; border-radius: 50%;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M3 10v4h4l5 5V5L7 10H3zm13.5 2a4.5 4.5 0 0 0-2.5-4v8a4.5 4.5 0 0 0 2.5-4z'/%3E%3C/svg%3E") center/contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M3 10v4h4l5 5V5L7 10H3zm13.5 2a4.5 4.5 0 0 0-2.5-4v8a4.5 4.5 0 0 0 2.5-4z'/%3E%3C/svg%3E") center/contain no-repeat;
}
.voice-wave { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.voice-wave i { display: block; width: 3px; height: 6px; border-radius: 2px; background: currentColor; opacity: .55; }
.voice-wave i:nth-child(2) { height: 10px; }
.voice-wave i:nth-child(3) { height: 14px; }
.voice-wave i:nth-child(4) { height: 8px; }
.bubble-voice.playing .voice-wave i { animation: voiceBar .8s ease-in-out infinite; }
.bubble-voice.playing .voice-wave i:nth-child(2) { animation-delay: .1s; }
.bubble-voice.playing .voice-wave i:nth-child(3) { animation-delay: .2s; }
.bubble-voice.playing .voice-wave i:nth-child(4) { animation-delay: .3s; }
@keyframes voiceBar {
  0%,100% { transform: scaleY(.55); }
  50% { transform: scaleY(1); }
}
.voice-label { font-size: 13px; font-weight: 600; }
.bubble-asr { margin-top: 6px; font-size: 13px; opacity: .85; line-height: 1.4; }
.bubble-video video {
  display: block; width: 100%; max-width: 260px; max-height: 320px;
  border-radius: 10px; background: #0b0d10;
}
.bubble-media-action {
  display: inline-block; margin-top: 6px; font-size: 12px; color: #2563eb; text-decoration: none;
}
.mchat-bubble.out .bubble-media-action, .bubble.out .bubble-media-action { color: #93c5fd; }
.bubble-file {
  display: flex; align-items: center; gap: 10px; max-width: 260px;
  padding: 10px 12px; border-radius: 12px; text-decoration: none;
  background: #f8fafc; border: 1px solid var(--line,#e5e7eb); color: #0f172a;
}
.mchat-bubble.out .bubble-file, .bubble.out .bubble-file {
  background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.18); color: #fff;
}
.file-icon {
  flex: 0 0 36px; width: 36px; height: 36px; border-radius: 8px; background: #e2e8f0;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6zm1 7V3.5L19.5 9H15z'/%3E%3C/svg%3E") center/22px no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6zm1 7V3.5L19.5 9H15z'/%3E%3C/svg%3E") center/22px no-repeat;
  background-color: #cbd5e1;
}
.mchat-bubble.out .file-icon, .bubble.out .file-icon { background-color: rgba(255,255,255,.35); }
.file-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.file-meta b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta small { font-size: 11px; opacity: .7; }
.msg-img-preview {
  position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.82);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.msg-img-preview[hidden] { display: none !important; }
.msg-img-preview img { max-width: min(96vw, 920px); max-height: 86vh; border-radius: 8px; }
.msg-img-close {
  position: absolute; top: 16px; right: 16px; border: 0; border-radius: 999px;
  padding: 8px 14px; background: #fff; color: #0f172a; font-weight: 600; cursor: pointer;
}
.msg-img-dl {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  color: #fff; font-size: 13px;
}



.ai-on-badge, .mchat-tag-ai {
  background: #0f172a !important; color: #fff !important;
  font-size: 11px !important; font-weight: 700; white-space: nowrap;
}
.mchat-tag-ai.ai-serving, .ai-serving-banner {
  background: linear-gradient(90deg, #0f172a, #1e293b);
  color: #fff;
}
.ai-serving-banner {
  flex: 0 0 auto;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
  border-bottom: 1px solid #1e293b;
  display: flex; align-items: center; gap: 8px;
}
.ai-serving-banner::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34,197,94,.25);
}
.msg-box { display: flex; flex-direction: column; }



/* chatux */
.chat-page-hd {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 10px; flex-wrap: wrap;
}
.chat-page-hd h3 { margin: 0; }
.chat-simple-filters { margin-bottom: 10px; }
.chat-advanced {
  margin: -2px 0 12px; padding: 10px; border: 1px dashed var(--line);
  border-radius: 8px; background: #f8fafc;
}
.chat-advanced-row { row-gap: 8px; }
.msg-box-hd {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 8px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  min-height: 52px;
}
.msg-box-hd-main { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-width: 0; }
.msg-box-title { font-size: 1rem; }
.msgs {
  flex: 1 1 auto; overflow: auto; padding: 14px;
  min-height: 320px;
  background:
    linear-gradient(90deg, rgba(0,0,0,.03) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(rgba(0,0,0,.03) 1px, transparent 1px) 0 0 / 24px 24px,
    #fff;
  border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px;
}
.chat-compose { display: flex; flex-direction: column; gap: 8px; }
.chat-textarea {
  width: 100%; min-height: 96px; resize: vertical;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; line-height: 1.5; box-sizing: border-box;
  background: #fff;
}
.chat-textarea:focus { outline: 2px solid #111; outline-offset: 1px; }
.chat-compose-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.chat-compose-left { flex: 1; }
.chat-send {
  min-width: 96px; height: 40px; padding: 0 22px;
  font-weight: 700;
}
.chat-ops { row-gap: 8px; }
.unread-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 7px; margin-left: auto;
  background: #ef4444; color: #fff; border-radius: 999px;
  font-size: 12px; font-weight: 800; line-height: 1;
  box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(239,68,68,.45);
  flex: 0 0 auto;
}
.conv-item-top { position: relative; }
.conv-item .unread-badge { margin-left: 6px; }
.conv-item.active .unread-badge {
  box-shadow: 0 0 0 2px #111, 0 2px 6px rgba(239,68,68,.45);
}
@media (max-width: 1100px) {
  .chat-layout { grid-template-columns: minmax(200px, 240px) 1fr; }
  .chat-crm { display: none; }
  .msg-box, .conv-list { height: calc(100vh - 240px); min-height: 420px; }
}


.conv-item { position: relative; padding-right: 36px; }
.conv-item .unread-badge {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  margin-left: 0; min-width: 24px; height: 24px; font-size: 13px;
  background: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.25), 0 2px 8px rgba(239,68,68,.5);
  animation: unread-pop .35s ease-out;
}
.conv-item.has-unread { background: #fff7f7; }
.conv-item.active.has-unread { background: #111; }
@keyframes unread-pop {
  from { transform: translateY(-50%) scale(.6); opacity: .4; }
  to { transform: translateY(-50%) scale(1); opacity: 1; }
}


/* chat-toolbar compose */
.chat-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 6px 0 8px; border-top: 1px solid var(--line2); margin-top: 4px;
}
.chat-tool-btn {
  background: #fff; border: 1px solid var(--line); color: var(--text);
  padding: 6px 12px; border-radius: 8px; font-size: .85rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
}
.chat-tool-btn:hover { border-color: #111; background: #f8fafc; }
.chat-tool-btn:disabled { opacity: .45; cursor: not-allowed; }
.voice-tool-ico {
  width: 14px; height: 14px; border-radius: 50%; background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 14a3 3 0 0 0 3-3V5a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3zm5-3a5 5 0 0 1-10 0H5a7 7 0 0 0 6 6.93V21h2v-3.07A7 7 0 0 0 19 11h-2z'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 14a3 3 0 0 0 3-3V5a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3zm5-3a5 5 0 0 1-10 0H5a7 7 0 0 0 6 6.93V21h2v-3.07A7 7 0 0 0 19 11h-2z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.chat-compose-inline {
  display: flex; align-items: flex-end; gap: 10px;
  flex-direction: row;
}
.chat-compose-inline .chat-textarea {
  flex: 1; min-height: 44px; max-height: 120px; rows: 2;
  margin: 0;
}
.chat-compose-inline .chat-send {
  flex: 0 0 auto; min-width: 88px; height: 44px;
}
.chat-pop-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 80;
}
.chat-pop {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: min(520px, calc(100vw - 32px)); max-height: min(72vh, 640px);
  background: #fff; border-radius: 12px; border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(0,0,0,.18); z-index: 81;
  display: flex; flex-direction: column; overflow: hidden;
}
.chat-pop-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line2);
}
.chat-pop-body { padding: 12px 14px 16px; overflow: auto; }
.chat-pop-list { display: flex; flex-direction: column; gap: 8px; }
.chat-pop-item {
  text-align: left; width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px;
}
.chat-pop-item:hover { border-color: #111; background: #f8fafc; }
.chat-pop-media {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px;
}
.chat-pop-media-item {
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  padding: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 6px;
  font-size: .78rem; text-align: left;
}
.chat-pop-media-item img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: #f1f5f9;
}
.chat-pop-media-item:hover { border-color: #111; }
.chat-pop-md textarea, .chat-pop-voice textarea {
  width: 100%; box-sizing: border-box; border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; font: inherit; resize: vertical;
}


/* input emoji + file */
.chat-input-wrap {
  position: relative; flex: 1; min-width: 0; display: flex; align-items: center;
}
.chat-input-wrap .chat-textarea,
.chat-input-wrap textarea {
  width: 100%; box-sizing: border-box; padding-right: 42px !important;
  margin: 0;
}
.chat-emoji-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: 0; border-radius: 8px;
  background: transparent; cursor: pointer; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: #64748b;
}
.chat-emoji-btn:hover { background: #f1f5f9; color: #0f172a; }
.chat-emoji-btn:disabled { opacity: .4; cursor: not-allowed; }
.emoji-ico {
  width: 20px; height: 20px; display: block; background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 2a10 10 0 1 0 .001 20.001A10 10 0 0 0 12 2zm0 2a8 8 0 1 1 0 16 8 8 0 0 1 0-16zm-3.5 5.5a1.25 1.25 0 1 1 0 2.5 1.25 1.25 0 0 1 0-2.5zm7 0a1.25 1.25 0 1 1 0 2.5 1.25 1.25 0 0 1 0-2.5zM12 16.5c-2.2 0-4-1.2-4-2.5h2c0 .5.9 1 2 1s2-.5 2-1h2c0 1.3-1.8 2.5-4 2.5z'/%3E%3C/svg%3E") center / contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 2a10 10 0 1 0 .001 20.001A10 10 0 0 0 12 2zm0 2a8 8 0 1 1 0 16 8 8 0 0 1 0-16zm-3.5 5.5a1.25 1.25 0 1 1 0 2.5 1.25 1.25 0 0 1 0-2.5zm7 0a1.25 1.25 0 1 1 0 2.5 1.25 1.25 0 0 1 0-2.5zM12 16.5c-2.2 0-4-1.2-4-2.5h2c0 .5.9 1 2 1s2-.5 2-1h2c0 1.3-1.8 2.5-4 2.5z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.chat-emoji-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px;
  max-height: 240px; overflow: auto;
}
.chat-emoji-item {
  border: 0; background: transparent; border-radius: 8px;
  font-size: 22px; line-height: 1.2; padding: 6px; cursor: pointer;
}
.chat-emoji-item:hover { background: #f1f5f9; }
.mchat-tools.chat-toolbar { margin-bottom: 8px; }
.mchat-input-row.chat-compose-inline { align-items: center; }
.mchat-ai-on { border-color: #2563eb !important; color: #2563eb !important; }
.chat-compose-inline { align-items: center; }


.tts-role-row{display:flex;align-items:center;gap:8px;margin-bottom:8px}
.tts-role-row label{flex:0 0 auto;font-size:12px}
.tts-voice-select{flex:1;min-width:0;height:34px;border:1px solid #d8dee6;border-radius:8px;padding:0 10px;background:#fff;font-size:13px}
.tts-preview-box{margin-top:10px;padding:8px;border-radius:10px;background:#f4f7fb;border:1px solid #e4ebf3}


/* mchat customer list: override global button{color:#fff} */
.mchat-item,
.mchat-sheet-item {
  display: flex !important;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line, #e5e7eb);
  background: #fff !important;
  color: #0b0d10 !important;
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 500;
  letter-spacing: normal;
  border-radius: 0;
}
.mchat-item:active,
.mchat-sheet-item:active { background: #f1f5f9 !important; }
.mchat-item b,
.mchat-sheet-item b,
.mchat-item-top b,
.mchat-sheet-item-top b {
  color: #0b0d10 !important;
  font-size: 15px;
  font-weight: 650;
}
.mchat-item .muted,
.mchat-sheet-item .muted,
.mchat-preview {
  color: #64748b !important;
  background: transparent !important;
}
.mchat-item-main { min-width: 0; flex: 1; }
.mchat-item-top,
.mchat-sheet-item-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}
.mchat-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #0b0d10 !important;
}
.mchat-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.mchat-scene {
  font-size: 11px;
  color: #64748b !important;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 1px 8px;
}
.mchat-preview {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.35;
  color: #64748b !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mchat-list { background: #f4f6f8; }
.mchat-hd {
  background: #fff !important;
  color: #0b0d10 !important;
}
.mchat-hd b, .mchat-hd .linkish { color: #0b0d10 !important; }

/* image icon button beside emoji */
.chat-img-btn {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 8px;
  background: transparent; color: #64748b;
  padding: 0; cursor: pointer;
}
.chat-img-btn:hover { background: #f1f5f9; color: #0f172a; }
.chat-img-btn:disabled { opacity: .4; cursor: not-allowed; }
.img-ico {
  display: block; width: 20px; height: 20px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Ccircle cx='8.5' cy='10' r='1.5'/%3E%3Cpath d='M21 16l-5-5-8 8'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Ccircle cx='8.5' cy='10' r='1.5'/%3E%3Cpath d='M21 16l-5-5-8 8'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* input icons inside box: image + emoji */
.chat-input-wrap {
  position: relative !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
  display: block !important;
  gap: 0 !important;
}
.chat-input-wrap .chat-textarea,
.chat-input-wrap textarea#replyText,
.mchat-input-row .chat-input-wrap textarea {
  display: block;
  width: 100% !important;
  flex: none !important;
  box-sizing: border-box;
  min-height: 44px;
  max-height: 96px;
  resize: none;
  margin: 0 !important;
  padding: 10px 78px 10px 12px !important;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  line-height: 1.4;
  color: #0b0d10;
}
.chat-input-wrap .chat-img-btn,
.chat-input-wrap .chat-emoji-btn {
  position: absolute !important;
  top: 50%;
  transform: translateY(-50%);
  width: 32px !important;
  height: 32px !important;
  flex: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 8px;
  background: transparent !important;
  color: #64748b !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: none !important;
}
.chat-input-wrap .chat-emoji-btn { right: 6px !important; left: auto !important; }
.chat-input-wrap .chat-img-btn { right: 38px !important; left: auto !important; }
.chat-input-wrap .chat-img-btn:hover,
.chat-input-wrap .chat-emoji-btn:hover {
  background: #f1f5f9 !important;
  color: #0f172a !important;
}
.mchat-input-row {
  display: flex !important;
  gap: 8px;
  align-items: flex-end !important;
}
.mchat-input-row .chat-input-wrap { flex: 1 1 auto !important; min-width: 0; }
.mchat-input-row > textarea { /* legacy direct textarea, ignore */
  display: none;
}
.mchat-send, .chat-send {
  flex: 0 0 auto !important;
  height: 44px;
  align-self: flex-end;
}
.chat-compose-inline {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

/* workbench: sidebar + topnav layout */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}
.work-pane {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: transparent;
}
.work-topnav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  min-height: 48px;
  background: #fff;
  border-bottom: 1px solid var(--line, #e5e7eb);
  position: sticky;
  top: 0;
  z-index: 20;
}
.work-topnav-tabs {
  display: flex;
  align-items: stretch;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.work-topnav-tabs::-webkit-scrollbar { display: none; }
.work-tab {
  flex: 0 0 auto;
  background: transparent !important;
  border: 0 !important;
  border-bottom: 2px solid transparent !important;
  border-radius: 0 !important;
  color: var(--muted, #5c6672) !important;
  padding: 14px 12px !important;
  font-weight: 600 !important;
  font-size: .88rem !important;
  letter-spacing: normal !important;
  white-space: nowrap;
  box-shadow: none !important;
}
.work-tab:hover { color: var(--text, #0b0d10) !important; background: transparent !important; }
.work-tab.active {
  color: var(--text, #0b0d10) !important;
  border-bottom-color: #111 !important;
  background: transparent !important;
}
.work-topnav-user {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.work-user-name { font-size: .85rem; color: var(--muted, #5c6672); }
.work-logout-btn { padding: 6px 12px !important; font-size: .8rem !important; }

.sidebar {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid var(--line, #e5e7eb);
  padding: 12px 10px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow: auto;
  z-index: 30;
}
.sidebar .brand {
  padding: 8px 12px 14px;
  flex: 0 0 auto;
}
.side-pri {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 0 10px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line, #e5e7eb);
}
.side-pri .side-btn {
  font-weight: 650;
  color: var(--text, #0b0d10);
  padding: 11px 12px;
}
.side-sec {
  color: #94a3b8;
  font-size: .68rem;
  padding: 12px 12px 4px;
  letter-spacing: .1em;
  text-transform: uppercase;
  font-weight: 700;
}
.side-btn {
  display: block;
  width: 100%;
  text-align: left;
  margin: 1px 0;
  padding: 9px 12px;
  background: transparent !important;
  border: 1px solid transparent !important;
  color: var(--muted, #5c6672) !important;
  font-weight: 500 !important;
  border-radius: 8px !important;
  letter-spacing: normal !important;
}
.side-btn:hover {
  background: #f3f4f6 !important;
  color: var(--text, #0b0d10) !important;
  border-color: transparent !important;
}
.side-btn.active {
  background: #111 !important;
  color: #fff !important;
  border-color: #111 !important;
}
.side-foot {
  margin-top: auto;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 10px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line, #e5e7eb);
  background: #fff;
  position: sticky;
  bottom: 0;
}
.side-user {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.side-user b {
  font-size: .9rem;
  color: var(--text, #0b0d10);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-user span { font-size: .72rem; color: #94a3b8; }
.side-logout {
  flex: 0 0 auto;
  padding: 6px 10px !important;
  font-size: .78rem !important;
  font-weight: 600 !important;
  background: #fff !important;
  border: 1px solid var(--line, #e5e7eb) !important;
  color: var(--text, #0b0d10) !important;
  border-radius: 8px !important;
}
.side-logout:hover { border-color: #111 !important; }

body.page-mchat .work-topnav { display: none !important; }

@media (max-width: 960px) {
  .work-topnav { padding: 0 10px; min-height: 44px; }
  .work-tab { padding: 12px 10px !important; font-size: .82rem !important; }
  .work-user-name { display: none; }
}

/* collapsible side groups */
.side-group { margin: 0; }
.side-sec-btn {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin: 4px 0 2px !important;
  padding: 8px 12px !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 8px !important;
  color: #94a3b8 !important;
  font-size: .68rem !important;
  font-weight: 700 !important;
  letter-spacing: .1em !important;
  text-transform: uppercase !important;
  cursor: pointer;
}
.side-sec-btn:hover { background: #f3f4f6 !important; color: #64748b !important; }
.side-sec-caret {
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  transition: transform .15s ease;
  transform: rotate(-90deg);
  opacity: .8;
}
.side-group.open .side-sec-caret { transform: rotate(0deg); }
.side-group-body {
  display: none;
  padding: 0 0 4px;
}
.side-group.open .side-group-body { display: block; }

.seat-cred-card { border: 1px solid #111; }
.seat-cred-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; margin-top: 8px;
}
.seat-cred-grid b { display: block; margin-top: 4px; font-size: 1.05rem; word-break: break-all; }

.cust-stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}
.cust-stat {
  background: #fff;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cust-stat b { font-size: 1.25rem; color: #0b0d10; letter-spacing: -.02em; }
.cust-stat span { font-size: 12px; color: #64748b; }

/* —— 我的机器人 tabs —— */
.bot-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 16px;
  padding: 4px;
  background: #f3f4f6;
  border-radius: 12px;
}
.bot-tab {
  border: none;
  background: transparent;
  color: #64748b;
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.bot-tab:hover { color: #0b0d10; background: rgba(255,255,255,.6); }
.bot-tab.active {
  background: #fff;
  color: #0b0d10;
  box-shadow: 0 1px 2px rgba(15,23,42,.08);
}
.bot-tab-body { display: grid; gap: 14px; }
.bot-stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 10px;
}
.bot-stat {
  background: #fff;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.bot-stat b { font-size: 1.2rem; color: #0b0d10; letter-spacing: -.02em; }
.bot-stat span { font-size: 12px; color: #64748b; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.card-head h3 { margin: 0; }
.bot-webhook { font-size: 12px; max-width: 280px; word-break: break-all; }
.bot-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.bot-copy-row {
  display: grid;
  gap: 10px;
  margin: 10px 0;
}
.bot-copy-row > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.bot-copy-row label {
  font-size: 12px;
  color: #64748b;
  min-width: 36px;
}
.bot-tips { margin: 8px 0 0; padding-left: 18px; }

/* —— 个人中心 —— */
.account-layout { display: grid; gap: 14px; max-width: 920px; }
.account-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
}
.account-avatar {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: #0b0d10;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 600;
  flex-shrink: 0;
}
.account-hero-main { flex: 1; min-width: 0; }
.account-name { font-size: 1.15rem; font-weight: 600; margin-bottom: 6px; }
.account-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: 13px; }
.account-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.account-assign-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
@media (max-width: 720px) {
  .account-grid { grid-template-columns: 1fr; }
  .account-hero { flex-wrap: wrap; }
  .bot-tabs { gap: 4px; }
  .bot-tab { padding: 7px 10px; font-size: 12px; }
}
