:root {
  --bg: #f8f3ed;
  --surface: #fffdfb;
  --surface-soft: #f4ebe3;
  --surface-warm: #f9e5d8;
  --line: #eaded4;
  --line-strong: #ddcabc;
  --text: #3e2c25;
  --muted: #907d72;
  --primary: #c85f3b;
  --primary-dark: #a94728;
  --primary-soft: #f7e2d6;
  --green: #427b5b;
  --green-soft: #e9f3ec;
  --red: #b34545;
  --red-soft: #fbeaea;
  --shadow: 0 14px 45px rgba(92, 54, 30, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 5% 0%, rgba(232, 167, 122, .17), transparent 34rem),
    radial-gradient(circle at 100% 100%, rgba(219, 150, 107, .12), transparent 32rem),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
a { color: var(--primary); }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(200, 95, 59, .2);
  outline-offset: 2px;
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(200, 95, 59, .08); outline: none; }
textarea { resize: vertical; min-height: 84px; }
label { display: grid; gap: 7px; font-weight: 600; font-size: 13px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(26px, 5vw, 34px); line-height: 1.25; letter-spacing: -.6px; }
h2 { font-size: 18px; line-height: 1.35; }
h3 { font-size: 14px; }
small { color: var(--muted); }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.stack { display: grid; gap: 16px; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button {
  display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px;
  border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--muted);
}
.icon-button:hover { color: var(--primary); border-color: var(--line-strong); background: var(--primary-soft); }
.button, button.primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px;
  padding: 9px 16px; border-radius: 11px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font-weight: 650; text-decoration: none;
}
.button:hover { background: var(--surface-soft); }
button.primary, .button.primary { border-color: var(--primary); background: var(--primary); color: white; box-shadow: 0 6px 14px rgba(200, 95, 59, .18); }
button.primary:hover, .button.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
button.danger { color: var(--red); border-color: #edc9c9; background: var(--red-soft); }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.button.full { width: 100%; }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 650; background: var(--surface-soft); color: var(--muted); white-space: nowrap; }
.badge.green { color: var(--green); background: var(--green-soft); }
.badge.orange { color: var(--primary-dark); background: var(--primary-soft); }
.badge.red { color: var(--red); background: var(--red-soft); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #b9aaa2; display: inline-block; }
.dot.online { background: #54a574; box-shadow: 0 0 0 3px rgba(84, 165, 116, .13); }
.avatar {
  position: relative; width: 42px; height: 42px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--primary-dark); background: linear-gradient(145deg, #f8ddcc, #f2c5aa); font-weight: 750; font-size: 16px; flex: none;
}
.avatar.small { width: 34px; height: 34px; border-radius: 11px; font-size: 13px; }
.avatar-letter { position: relative; }
.avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.presence-dot { position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; background: #b9aaa2; border: 2px solid var(--surface); z-index: 1; }
.presence-dot.online { background: #54a574; }
.avatar-button { border: 0; background: transparent; padding: 0; border-radius: 11px; cursor: pointer; line-height: 0; }
.avatar-button:hover .avatar { box-shadow: 0 0 0 2px var(--primary); }
.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 750; letter-spacing: -.2px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 13px; display: inline-flex; align-items: center; justify-content: center;
  color: white; background: linear-gradient(145deg, #dd8059, #b84f2f); box-shadow: 0 6px 16px rgba(184, 79, 47, .22);
}
.brand-mark .icon { width: 22px; height: 22px; }

/* Login */
.login-page { min-height: 100%; display: grid; grid-template-columns: 1.05fr .95fr; }
.login-story {
  position: relative; overflow: hidden; padding: clamp(28px, 5vw, 70px); display: flex; flex-direction: column; justify-content: space-between;
  color: #fff9f4; background: linear-gradient(145deg, #9f492f 0%, #c76743 52%, #dd9870 100%);
}
.login-story::before, .login-story::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.17); border-radius: 50%; }
.login-story::before { width: 480px; height: 480px; right: -180px; top: 12%; }
.login-story::after { width: 310px; height: 310px; left: -130px; bottom: -90px; }
.login-story .brand-mark { background: rgba(255,255,255,.17); box-shadow: none; border: 1px solid rgba(255,255,255,.25); }
.story-content { position: relative; max-width: 490px; margin: auto 0; padding: 50px 0; }
.story-content h1 { font-size: clamp(34px, 4.5vw, 56px); margin-bottom: 20px; letter-spacing: -1.4px; }
.story-content p { color: rgba(255,249,244,.8); font-size: 17px; max-width: 420px; }
.story-points { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
.story-points span { padding: 7px 12px; border-radius: 999px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.16); font-size: 13px; }
.story-foot { position: relative; color: rgba(255,249,244,.65); font-size: 12px; }
.login-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 32px 20px; }
.login-card { width: min(100%, 400px); }
.login-card .eyebrow { color: var(--primary); font-weight: 750; font-size: 12px; letter-spacing: 2px; margin-bottom: 10px; }
.login-card h2 { font-size: 28px; margin-bottom: 8px; }
.login-card > p { color: var(--muted); margin-bottom: 28px; }
.login-form { display: grid; gap: 18px; }
.code-field { position: relative; }
.code-field input { padding-right: 116px; }
.code-field button { position: absolute; right: 5px; bottom: 5px; min-height: 34px; padding: 5px 10px; font-size: 12px; }
.segmented { display: flex; padding: 4px; background: var(--bg); border-radius: 12px; gap: 4px; }
.segmented button { flex: 1; border: 0; border-radius: 9px; padding: 9px; background: transparent; color: var(--muted); }
.segmented button.active { background: var(--surface); color: var(--primary-dark); box-shadow: 0 1px 4px #4b2c1712; font-weight: 650; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 4px 0; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.wechat-button { border-color: #cfe6d6; color: #34704c; background: #f1f8f3; }
.wechat-login-top { min-height: 46px; margin-top: 2px; }
.login-card .divider { margin: 14px 0 18px; }
.demo-note { margin-top: 20px; padding: 12px 14px; border-radius: 12px; background: #fff4df; border: 1px solid #f1dfba; color: #86672c; font-size: 12px; }
.demo-note strong { display: block; margin-bottom: 2px; }
.error-note { margin-top: 16px; padding: 11px 13px; border-radius: 11px; background: var(--red-soft); color: var(--red); font-size: 13px; }

/* Workspace */
.workspace { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.app-header {
  height: 72px; flex: none; display: flex; align-items: center; gap: 18px; padding: 0 24px;
  background: rgba(255,253,251,.88); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px); z-index: 5;
}
.app-header .brand-text { font-size: 16px; }
.header-meta { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.connection { font-size: 12px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.user-chip { display: flex; align-items: center; gap: 9px; padding-left: 14px; border-left: 1px solid var(--line); }
.user-chip strong { font-size: 13px; }
.app-nav { display: flex; gap: 4px; margin-left: 18px; }
.app-nav button { border: 0; background: transparent; color: var(--muted); padding: 8px 12px; border-radius: 9px; font-weight: 600; }
.app-nav button.active { color: var(--primary-dark); background: var(--primary-soft); }
.workspace-body { flex: 1; min-height: 0; display: flex; }
.conversation-sidebar { width: 310px; flex: none; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); }
.sidebar-heading { padding: 20px 18px 12px; }
.sidebar-heading h2 { margin-bottom: 13px; display: flex; align-items: center; justify-content: space-between; }
.search-box { position: relative; }
.search-box .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); }
.search-box input { padding-left: 36px; background: var(--bg); border-color: transparent; }
.sidebar-heading select { margin-top: 9px; width: 100%; }
.sidebar-filters { display: flex; gap: 8px; }
.sidebar-filters select { margin-top: 9px; width: 50%; min-width: 0; }
.pin-mark { font-size: 10px; color: var(--primary-dark); background: var(--primary-soft); border-radius: 4px; padding: 2px 4px; margin-right: 5px; }
.conversation-list { overflow-y: auto; padding: 5px 10px 16px; flex: 1; }
.conversation-item { width: 100%; display: flex; gap: 11px; align-items: center; text-align: left; border: 1px solid transparent; background: transparent; padding: 12px 10px; border-radius: 13px; margin-bottom: 3px; color: var(--text); }
.conversation-item:hover { background: var(--bg); }
.conversation-item.active { background: var(--primary-soft); border-color: #f0d3c3; }
.conversation-copy { min-width: 0; flex: 1; }
.conversation-top { display: flex; align-items: center; gap: 8px; }
.conversation-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.conversation-top time { margin-left: auto; color: var(--muted); font-size: 11px; flex: none; }
.conversation-preview { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; margin-top: 3px; }
.unread-count { min-width: 18px; height: 18px; padding: 0 5px; display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 999px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; }
.conversation-menu { position: fixed; z-index: 50; width: 164px; padding: 5px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); box-shadow: 0 10px 30px rgba(62, 44, 37, .16); }
.conversation-menu[hidden] { display: none; }
.conversation-menu button { display: block; width: 100%; padding: 9px 12px; border: 0; border-radius: 7px; background: transparent; color: var(--text); text-align: left; font-size: 13px; }
.conversation-menu button:hover { background: var(--bg); }
.conversation-menu button.danger { color: var(--red); }
.conversation-menu button.danger:hover { background: var(--red-soft); }
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.tag { display: inline-flex; padding: 1px 7px; border-radius: 999px; background: var(--surface-warm); color: #9c5c3d; font-size: 11px; }
.empty-list { padding: 40px 18px; text-align: center; color: var(--muted); }
.list-section-title { display: flex; align-items: center; gap: 8px; padding: 12px 10px 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.search-result { width: 100%; display: block; text-align: left; border: 1px solid transparent; background: transparent; padding: 10px; border-radius: 13px; margin-bottom: 3px; color: var(--text); }
.search-result:hover { background: var(--bg); }
.search-result-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.search-result-head strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result-head time { margin-left: auto; color: var(--muted); font-size: 11px; flex: none; }
.search-result-snippet { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; }
mark { background: #ffe1a8; color: #7a4a12; border-radius: 3px; padding: 0 1px; }
.chat-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #fffcf9; }
.chat-head { flex: none; min-height: 78px; display: flex; align-items: center; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: rgba(255,253,251,.8); }
.chat-head h2 { margin: 0; font-size: 16px; }
.chat-head-customer { min-width: 0; }
.chat-head-title-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.chat-head-title-row h2 { max-width: min(34vw, 420px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-edit-button { width: 28px; height: 28px; flex: none; border: 0; background: transparent; color: #9a887d; }
.header-edit-button:hover { background: #f4ece6; color: var(--primary); }
.header-edit-button .icon { width: 15px; height: 15px; }
.header-remark-form { display: flex; align-items: center; gap: 4px; min-width: 0; }
.header-remark-form input { width: min(360px, 38vw); min-width: 150px; height: 34px; padding: 5px 9px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; color: var(--text); }
.header-remark-form .icon-button { width: 30px; height: 30px; flex: none; }
.header-remark-form .icon { width: 16px; height: 16px; }
.chat-head p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.chat-head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.back-button { display: none; }
.timeline { flex: 1; min-height: 0; overflow-y: auto; padding: 26px clamp(18px, 4vw, 48px); scroll-behavior: smooth; }
.date-separator { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 11px; margin: 8px 0 22px; }
.date-separator::before, .date-separator::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.message { display: flex; gap: 10px; margin-bottom: 20px; align-items: flex-start; }
.message.mine { flex-direction: row-reverse; }
.message .avatar { width: 34px; height: 34px; border-radius: 11px; font-size: 12px; }
.message-body { max-width: min(70%, 680px); }
.message-meta { color: var(--muted); font-size: 11px; margin: 0 0 5px 3px; }
.message.mine .message-meta { text-align: right; margin-right: 3px; }
.read-receipt { margin-top: 4px; font-size: 11px; color: #b9aaa2; text-align: right; }
.read-receipt.read { color: #a8988e; }
.message.flash { animation: jump-flash 1.8s ease; border-radius: 14px; }
@keyframes jump-flash { 0%, 55% { background: #ffe9d2; } 100% { background: transparent; } }
.bubble { padding: 11px 15px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px 15px 15px 15px; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 3px 10px rgba(92,54,30,.03); }
.message.mine .bubble { background: #cf6a45; border-color: #cf6a45; color: white; border-radius: 15px 4px 15px 15px; }
.system-message { justify-content: center; color: var(--muted); font-size: 12px; margin: 10px 0 18px; text-align: center; }
.gift-card { min-width: 230px; display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 14px; background: linear-gradient(135deg, #fff0dc, #f8d9be); border: 1px solid #edc39e; color: #8a492b; }
.gift-icon { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: #c9633d; color: #fff; flex: none; }
.gift-card strong { display: block; font-size: 15px; }
.gift-card small { color: #a36949; }
.gift-card .gift-error { display: block; margin-top: 4px; color: #b42318; line-height: 1.4; }
.gift-card button { margin-left: auto; }
.composer-wrap { flex: none; padding: 14px 24px 20px; background: #fffcf9; border-top: 1px solid var(--line); }
.composer { position: relative; display: block; padding: 10px; border: 1px solid var(--line-strong); border-radius: 16px; background: var(--surface); box-shadow: 0 5px 18px rgba(92,54,30,.04); }
.composer:focus-within { border-color: #d79b7e; }
.composer-main { display: flex; align-items: flex-end; gap: 10px; }
.composer textarea { border: 0; box-shadow: none; padding: 7px 5px; min-height: 42px; max-height: 130px; resize: none; background: transparent; }
.composer .send-button { width: 42px; height: 42px; padding: 0; border-radius: 12px; flex: none; }
.composer-toolbar { display: flex; align-items: center; gap: 4px; padding: 0 2px 5px; border-bottom: 1px solid #f0e9e3; margin-bottom: 6px; }
.composer-tool { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 9px; background: transparent; color: #7b6b62; cursor: pointer; }
.composer-tool:hover { background: #f6efe9; color: var(--primary); }
.composer-tool .icon { width: 20px; height: 20px; }
.composer-tool.gift-tool { color: #c44d4d; }
.emoji-picker { position: absolute; left: 8px; bottom: calc(100% + 8px); display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; width: 196px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 12px 32px rgba(62,44,37,.16); z-index: 5; }
.emoji-picker[hidden] { display: none; }
.emoji-picker button { border: 0; border-radius: 8px; padding: 6px; background: transparent; font-size: 20px; cursor: pointer; }
.emoji-picker button:hover { background: #f6efe9; }
.composer-hint { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 7px; padding: 0 4px; }
.detail-sidebar { width: 290px; flex: none; background: var(--surface); border-left: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; }
.detail-tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 12px; flex: none; }
.detail-tabs button { flex: 1; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); padding: 17px 4px 13px; font-size: 13px; font-weight: 650; }
.detail-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.detail-content { padding: 18px; overflow-y: auto; flex: 1; }
.detail-section { margin-bottom: 24px; }
.detail-section h3 { margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.detail-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; font-size: 13px; border-bottom: 1px dashed var(--line); }
.detail-row span:first-child { color: var(--muted); }
.quick-search { margin-bottom: 12px; }
.quick-item { display: flex; align-items: flex-start; gap: 5px; }
.quick-item .quick-reply { flex: 1; min-width: 0; }
.quick-item .icon-button { flex: none; margin-top: 4px; }
.tag-group { margin: 12px 0; }
.tag-group > strong { font-size: 12px; color: var(--primary-dark); }
.tag-options { display: flex; flex-wrap: wrap; gap: 8px 12px; margin: 7px 0 12px; }
.tag-options .check-label { font-size: 12px; }
.tag-manage-button { padding: 5px 10px; font-size: 12px; font-weight: 500; }
.tag-manage-group { margin-top: 18px; }
.tag-manage-group h3 { margin: 0 0 8px; font-size: 13px; color: var(--primary-dark); }
.tag-manage-list { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tag-manage-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.tag-manage-row:last-child { border-bottom: 0; }
.tag-manage-row span { min-width: 0; overflow-wrap: anywhere; }
.tag-manage-row .button { flex: none; padding: 5px 10px; font-size: 12px; }
.remark-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; min-width: 0; }
.remark-input { width: 180px; min-width: 100px; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input { flex: 1; min-width: 0; }
.password-setup { background: var(--primary-soft); border-bottom: 1px solid #efd5c5; padding: 12px 20px; font-size: 13px; }
.password-setup .inline-form { margin-top: 8px; }
.quick-group { margin-bottom: 12px; }
.quick-group summary { cursor: pointer; font-weight: 650; padding: 7px 0; color: var(--primary-dark); }
.quick-reply { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--bg); color: var(--text); padding: 10px 12px; border-radius: 10px; margin-bottom: 7px; font-size: 12px; }
.quick-reply:hover { border-color: #dca88e; background: var(--primary-soft); }
.quick-reply strong { display: block; margin-bottom: 3px; }
.quick-reply span { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tag-editor { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }

/* Customer */
.customer-page { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.customer-shell { width: min(100%, 940px); height: min(850px, calc(100dvh - 48px)); background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.customer-header { padding: 18px 24px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); background: #fffaf6; }
.customer-header h1 { font-size: 18px; margin: 0; letter-spacing: 0; }
.customer-header p { margin: 1px 0 0; font-size: 12px; color: var(--muted); }
.customer-chat { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #fffcf9; }
.welcome-card { margin: 22px auto 0; max-width: 80%; text-align: center; color: var(--muted); font-size: 12px; background: var(--surface-soft); padding: 9px 15px; border-radius: 999px; }
.welcome-editor { margin-top: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.welcome-editor > strong { display: block; font-size: 14px; color: var(--text); }
.welcome-editor > .muted { margin: 4px 0 12px; font-size: 12px; }
.welcome-list { display: flex; flex-direction: column; gap: 10px; }
.welcome-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.welcome-preview { flex: 1; min-width: 0; font-size: 13px; color: var(--text); word-break: break-word; }
.welcome-preview img { max-width: 120px; max-height: 90px; border-radius: 8px; display: block; }
.welcome-item-actions { display: flex; gap: 4px; flex: none; }
.welcome-item-actions .icon-button { width: 30px; height: 30px; }
.welcome-add { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.welcome-add textarea { width: 100%; min-height: 64px; resize: vertical; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); font: inherit; color: var(--text); }
.welcome-add .row { display: flex; gap: 8px; flex-wrap: wrap; }
.customer-identity { margin-left: auto; display: flex; align-items: center; gap: 8px; text-align: right; font-size: 12px; color: var(--muted); }
.avatar-editor { text-align: center; }
.avatar-preview { display: flex; justify-content: center; margin-bottom: 14px; }
.avatar-preview .avatar { width: 84px; height: 84px; border-radius: 26px; font-size: 30px; }
.avatar-editor .modal-actions { justify-content: center; flex-wrap: wrap; }
.sound-toggle { min-height: 34px; padding: 6px 11px; font-size: 12px; flex: none; }
.sound-toggle .icon { width: 16px; height: 16px; }

/* Admin pages */
.admin-page { flex: 1; min-height: 0; overflow-y: auto; padding: 30px clamp(18px, 4vw, 48px) 60px; }
.admin-container { max-width: 1080px; margin: 0 auto; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-heading h1 { font-size: 26px; margin-bottom: 5px; letter-spacing: -.4px; }
.page-heading p { margin: 0; color: var(--muted); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; }
.stat-card span { color: var(--muted); font-size: 12px; }
.stat-card strong { display: block; font-size: 26px; margin-top: 5px; letter-spacing: -.6px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; box-shadow: 0 4px 20px rgba(92,54,30,.025); }
.card h2 { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 700px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 600; background: #fcf8f4; }
tr:last-child td { border-bottom: 0; }
.reply-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.reply-card { border: 1px solid var(--line); border-radius: 13px; padding: 14px; background: #fffaf6; }
.reply-card h3 { margin-bottom: 5px; }
.reply-card p { color: var(--muted); font-size: 13px; margin-bottom: 12px; white-space: pre-wrap; }
.reply-card .row { justify-content: space-between; }
.agent-list { display: grid; gap: 10px; margin-top: 16px; }
.agent-row { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); padding: 12px; border-radius: 12px; flex-wrap: wrap; }
.agent-row > div { min-width: 0; }
.agent-row p { margin: 0; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.config-list { display: grid; gap: 10px; }
.config-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.config-row:last-child { border-bottom: 0; }
.filter-row { display: flex; gap: 10px; margin-bottom: 16px; }
.filter-row select { max-width: 180px; }

/* Dialog and toast */
dialog { width: min(calc(100% - 32px), 470px); border: 1px solid var(--line); border-radius: 20px; padding: 0; color: var(--text); background: var(--surface); box-shadow: 0 28px 80px rgba(62,44,37,.2); }
dialog::backdrop { background: rgba(48, 32, 24, .38); backdrop-filter: blur(3px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 12px; }
.modal-head h2 { margin: 0; font-size: 19px; }
.modal-body { padding: 4px 22px 22px; }
.modal-body > p { color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.message-title { display: inline-block; padding: 3px 9px; border-radius: 6px; margin-bottom: 6px; font-size: 13px; line-height: 1.5; }
.style-blue { color: #2563eb; background: #e8f1ff; }
.style-green { color: #198754; background: #e9f7ef; }
.style-gray { color: #495057; background: #f1f3f5; }
.style-pink { color: #d6336c; background: #fff0f3; }
.style-yellow { color: #9a6b00; background: #fff7df; }
.quick-reply .message-title { width: fit-content; }
.message-image { display: block; max-width: min(100%, 360px); max-height: 360px; border-radius: 8px; }
.message-video { display: block; width: min(100%, 420px); max-height: 320px; border-radius: 8px; background: #111; }
.message-file { display: flex; align-items: center; gap: 12px; min-width: 220px; max-width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); text-decoration: none; }
.message-file-icon { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none; border-radius: 10px; background: #f6efe9; color: var(--primary); }
.message-file strong { display: block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.message-file small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
dialog.quick-reply-modal { width: min(calc(100% - 32px), 760px); border: 1px solid #e2e5e9; border-radius: 14px; background: #fff; box-shadow: 0 24px 70px rgba(15, 23, 42, .22); }
.quick-reply-modal::backdrop { background: rgba(31, 41, 55, .48); backdrop-filter: blur(2px); }
.quick-reply-modal .modal-head { padding: 24px 28px 20px; }
.quick-reply-modal .modal-head h2 { color: #1f2937; font-size: 20px; font-weight: 700; }
.quick-reply-modal .modal-head .icon-button { width: 32px; height: 32px; border: 1px solid #e5e7eb; border-radius: 8px; background: #fff; color: #6b7280; }
.quick-reply-modal .modal-body { padding: 0 28px 26px; }
.quick-reply-form { color: #374151; }
.quick-reply-row { display: grid; grid-template-columns: 92px minmax(0, 1fr); align-items: start; gap: 24px; margin-bottom: 22px; }
.quick-reply-label { padding-top: 10px; color: #374151; font-size: 14px; font-weight: 600; white-space: nowrap; }
.quick-reply-control { min-width: 0; }
.quick-reply-form input:not([type="radio"]), .quick-reply-form textarea, .quick-reply-form select { width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; color: #1f2937; font-size: 14px; font-weight: 400; box-shadow: none; }
.quick-reply-form input::placeholder, .quick-reply-form textarea::placeholder { color: #9ca3af; }
.quick-reply-form input:focus, .quick-reply-form textarea:focus, .quick-reply-form select:focus { border-color: #15803d; box-shadow: 0 0 0 3px rgba(21, 128, 61, .1); }
.quick-reply-form textarea { min-height: 136px; resize: vertical; line-height: 1.6; }
.reply-media-field { width: 100%; }
.reply-upload-button { width: 100%; min-height: 44px; padding: 10px 14px; border: 1px dashed #9bb8ae; border-radius: 7px; background: #f7fbf9; color: #146c5a; font-weight: 600; cursor: pointer; }
.reply-upload-button:hover { background: #eef7f3; }
.reply-media-preview { margin-top: 10px; }
.reply-media-preview img, .reply-media-preview video { display: block; width: 100%; max-height: 220px; object-fit: contain; border: 1px solid #e5e7eb; border-radius: 8px; background: #f8fafc; }
.reply-upload-empty { display: grid; place-items: center; min-height: 92px; border: 1px dashed #e0e5e2; border-radius: 8px; background: #fafcfb; color: #8a9691; font-size: 13px; }
.reply-upload-hint { display: block; margin-top: 8px; color: #6b7280; font-size: 12px; line-height: 1.5; }
.reply-style-options { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; min-height: 42px; }
.reply-style-option { display: inline-flex; align-items: center; gap: 7px; font-weight: 400; }
.reply-style-option input, .reply-type-options input { width: 14px; height: 14px; margin: 0; flex: none; accent-color: #2563eb; }
.reply-style-option span { display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 6px; font-size: 13px; line-height: 1.4; }
.reply-type-options { display: flex; align-items: center; gap: 30px; min-height: 42px; }
.reply-type-options label { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; }
.reply-group-select-row, .new-reply-group-fields { display: flex; align-items: center; gap: 10px; }
.reply-group-select-row[hidden], .new-reply-group-fields[hidden] { display: none; }
.reply-group-select-row select, .new-reply-group-fields input { flex: 1; min-width: 0; }
.reply-group-add, .reply-group-cancel { min-height: 42px; padding: 8px 16px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; color: #374151; font-weight: 500; white-space: nowrap; }
.reply-group-add:hover, .reply-group-cancel:hover { background: #f9fafb; }
.reply-group-cancel { color: #6b7280; }
.quick-reply-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; padding-top: 20px; border-top: 1px solid #edf0f2; }
.quick-reply-save, .quick-reply-cancel { min-height: 40px; padding: 8px 20px; border-radius: 6px; font-size: 14px; font-weight: 600; }
.quick-reply-save { border: 1px solid #146c5a; background: #146c5a; color: #fff; }
.quick-reply-save:hover { border-color: #0e5a49; background: #0e5a49; }
.quick-reply-save.continue { border-color: #0e5a49; background: #0e5a49; }
.quick-reply-save.continue:hover { background: #0a4c3c; }
.quick-reply-cancel { border: 1px solid #d1d5db; background: #fff; color: #374151; }
.quick-reply-cancel:hover { background: #f9fafb; }
.amount-input { position: relative; }
.amount-input span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 24px; color: var(--primary); font-weight: 700; }
.amount-input input { font-size: 26px; font-weight: 700; padding: 14px 14px 14px 42px; height: 64px; }
.check-label { display: flex; align-items: flex-start; gap: 9px; font-weight: 500; line-height: 1.5; }
.check-label input { width: 17px; height: 17px; margin-top: 2px; flex: none; accent-color: var(--primary); }
#toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: #3e2c25; color: white; border-radius: 12px; padding: 11px 18px; box-shadow: var(--shadow); z-index: 100; transition: .2s; max-width: calc(100% - 32px); text-align: center; }
#toast.show { transform: translate(-50%, 0); opacity: 1; }
#toast.error { background: #9c3f3f; }
.loading-page { min-height: 100dvh; display: grid; place-items: center; color: var(--muted); }
.loader { width: 32px; height: 32px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1180px) {
  .detail-sidebar { width: 250px; }
  .conversation-sidebar { width: 275px; }
  .app-nav { margin-left: 0; }
  .app-nav button { padding: 8px 9px; }
}
@media (max-width: 980px) {
  .detail-sidebar { position: fixed; right: 0; top: 72px; bottom: 0; z-index: 12; width: min(320px, 88vw); box-shadow: -16px 0 40px rgba(62,44,37,.12); transform: translateX(105%); transition: transform .2s; }
  .detail-sidebar.open { transform: translateX(0); }
  .login-story { padding: 36px; }
  .header-meta .connection { display: none; }
}
@media (max-width: 760px) {
  .login-page { grid-template-columns: 1fr; }
  .login-story { min-height: 220px; padding: 24px; }
  .story-content { padding: 28px 0 12px; margin: 0; }
  .story-content h1 { font-size: 30px; max-width: 300px; margin-bottom: 10px; }
  .story-content p, .story-points, .story-foot { display: none; }
  .login-panel { padding: 30px 22px 40px; align-items: flex-start; }
  .app-header { height: 62px; padding: 0 14px; gap: 8px; }
  .app-header .brand-text { font-size: 14px; }
  .app-header .brand-mark { width: 33px; height: 33px; border-radius: 11px; }
  .app-nav { order: 3; position: fixed; left: 0; right: 0; bottom: 0; height: 58px; background: var(--surface); border-top: 1px solid var(--line); justify-content: space-around; padding: 5px 8px calc(5px + env(safe-area-inset-bottom)); z-index: 20; }
  .app-nav button { flex: 1; font-size: 12px; padding: 8px 4px; }
  .user-chip { border: 0; padding: 0; }
  .user-chip .avatar { display: none; }
  .user-chip .avatar-button .avatar { display: inline-flex; width: 30px; height: 30px; border-radius: 10px; }
  .user-chip strong { display: none; }
  .workspace-body { padding-bottom: 58px; }
  .conversation-sidebar { width: 100%; border: 0; }
  .workspace-body.chat-open .conversation-sidebar { display: none; }
  .workspace-body:not(.chat-open) .chat-panel { display: none; }
  .chat-head { padding: 10px 12px; min-height: 68px; }
  .customer-chat > .chat-head { display: none; }
  .back-button { display: inline-flex; }
  .chat-head-actions .button span { display: none; }
  .chat-head-actions .button { padding: 8px 10px; }
  .timeline { padding: 18px 14px; }
  .message-body { max-width: 82%; }
  .composer-wrap { padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); }
  .composer-hint { display: none; }
  .detail-sidebar { top: 62px; bottom: 58px; }
  .customer-page { padding: 0; }
  .customer-shell { width: 100%; height: 100dvh; border: 0; border-radius: 0; }
  .customer-header { padding: 13px 15px; }
  .customer-identity { display: none; }
  .sound-toggle span { display: none; }
  .sound-toggle { padding: 8px; }
  .welcome-card { max-width: 90%; margin-top: 15px; }
  .admin-page { padding: 22px 14px 40px; }
  .stat-grid { grid-template-columns: 1fr; gap: 9px; }
  .stat-card { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; }
  .stat-card strong { font-size: 22px; margin: 0; }
  .form-grid, .reply-grid { grid-template-columns: 1fr; }
  .card { padding: 17px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .page-heading .button { width: 100%; }
}
@media (max-width: 640px) {
  .quick-reply-modal .modal-head { padding: 20px 18px 16px; }
  .quick-reply-modal .modal-head h2 { font-size: 18px; }
  .quick-reply-modal .modal-body { padding: 0 18px 20px; }
  .quick-reply-row { grid-template-columns: 1fr; gap: 8px; margin-bottom: 18px; }
  .quick-reply-label { padding-top: 0; }
  .reply-style-options { gap: 10px 12px; }
  .reply-type-options { gap: 22px; }
  .quick-reply-actions { flex-wrap: wrap; }
  .quick-reply-save, .quick-reply-cancel { flex: 1; padding-inline: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.app-download-entry {
  width: min(100%, 400px); display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-radius: 16px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px dashed var(--line-strong);
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.app-download-entry:hover { border-color: var(--primary); border-style: solid; box-shadow: var(--shadow); transform: translateY(-1px); }
.app-download-entry svg { width: 21px; height: 21px; color: var(--primary); flex: none; }
.app-download-entry strong { display: block; font-size: 14px; }
.app-download-entry small { color: var(--muted); font-size: 12px; }
.app-download-entry .entry-arrow { margin-left: auto; color: var(--muted); font-size: 16px; }
.app-download-button { display: none; text-decoration: none; }
.wechat-jump p { font-size: 14px; margin-bottom: 10px; }
.wechat-jump ol { margin: 0 0 6px 20px; display: grid; gap: 6px; color: var(--muted); font-size: 13.5px; }
@media (max-width: 900px) {
  .app-download-button { display: inline-flex; padding: 8px 12px; }
  .app-download-button span { font-size: 12px; }
}
@media (max-width: 640px) {
  .app-download-button span { display: none; }
  .app-download-button { padding: 8px; }
}
