/* LinkDesk 正式页面样式：取自已确认设计稿 design/ui.css，只保留真实页面用到的部分。 */
:root {
  --ink: #10302a; --ink-2: #1a443b; --ink-3: #2a5a4e; --on-ink: #e8f1ed; --on-ink-2: #b4cbc2;
  --canvas: #f3f1ec; --panel: #fff; --panel-2: #faf9f6; --line: #e3e0d8; --line-2: #cfcbc0;
  --text: #1c2624; --text-2: #55615c; --text-3: #6a746f;
  --green: #0f7a55; --green-d: #0b6245; --green-bg: #e6f3ec;
  --amber: #8f5300; --amber-dot: #d98a12; --amber-bg: #fcf2dd; --amber-line: #eed9ac;
  --red: #ad332a; --red-d: #8f2820; --red-bg: #fbeae7; --red-line: #f0cbc6;
  --r-s: 4px; --r-m: 6px; --r-l: 10px;
  --shadow: 0 1px 2px rgba(16, 48, 42, .05), 0 8px 24px rgba(16, 48, 42, .07);
  --shadow-l: 0 2px 6px rgba(16, 48, 42, .1), 0 24px 56px rgba(16, 48, 42, .2);
  --latin: "Avenir Next", Avenir, "Segoe UI", "PingFang SC", sans-serif;
  --body: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body { margin: 0; background: var(--canvas); color: var(--text); font: 14px/1.6 var(--body); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: var(--r-s); }
main:focus, .ws-main:focus { outline: none; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 70; padding: 6px 12px; border-radius: var(--r-m); background: var(--panel); }
.skip-link:focus { top: 8px; }
.ic { width: 18px; height: 18px; flex: none; display: block; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
[data-icon] { display: inline-flex; flex: none; }
.num { font-family: var(--latin); font-variant-numeric: tabular-nums; letter-spacing: .01em; }

/* 按钮 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--r-m); background: var(--panel); font-weight: 500; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover:not(:disabled) { background: var(--panel-2); border-color: #b7b3a8; }
.btn:disabled { color: #8a918d; background: #f1efea; border-color: var(--line); }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--green-d); border-color: var(--green-d); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-small { min-height: 28px; padding: 0 9px; font-size: 13px; }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn .spin { display: none; }
.btn.is-busy .spin { display: block; }
.btn.is-busy [data-icon] { display: none; }

/* 状态点、状态条 */
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: #8a918d; }
.dot.ok { background: #17a26f; }
.dot.wait { background: var(--amber-dot); }
.dot.bad { background: var(--red); }
.notice { display: block; flex: none; padding: 8px 14px; font-size: 13px; line-height: 1.5; border-bottom: 1px solid var(--line); background: var(--panel-2); color: var(--text-2); overflow-wrap: anywhere; }
.notice.wait { background: var(--amber-bg); border-color: var(--amber-line); color: var(--amber); }
.notice.bad { background: var(--red-bg); border-color: var(--red-line); color: var(--red); }
.notice.ok { background: var(--green-bg); border-color: #cae4d6; color: var(--green-d); }

/* 字段 */
.field-label { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 500; }
.input { display: block; width: 100%; min-height: 36px; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: var(--r-m); background: var(--panel); }
.input::placeholder, .composer-input::placeholder { color: var(--text-3); }
.field-error { margin-top: 4px; color: var(--red); font-size: 13px; }

/* 消息与滚动 */
.timeline-wrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.messages { display: flex; flex-direction: column; }
.jump { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); box-shadow: var(--shadow); }

/* ———— 客户窗口 ———— */
.cl-body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.cl-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 24px; }
.cl-window { display: flex; flex-direction: column; width: 100%; max-width: 420px; height: 100%; max-height: 720px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow); overflow: hidden; }
.cl-head { display: flex; align-items: center; gap: 10px; flex: none; padding: 12px 14px; background: var(--ink); color: var(--on-ink); }
.cl-head .brand-mark { width: 30px; height: 30px; }
.cl-head-text { min-width: 0; flex: 1; }
.cl-brand { font: 600 15px/1.3 var(--latin); }
.cl-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--on-ink-2); }
.cl-log { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; background: var(--panel-2); }
.cl-log > :first-child { margin-top: auto; }
.cl-log .messages { gap: 12px; }
.cl-log .welcome[hidden] + .messages { margin-top: auto; }
.bubble-row { display: flex; flex-direction: column; align-items: flex-start; max-width: 84%; animation: rise .16s ease-out; }
.bubble-row.me { align-self: flex-end; align-items: flex-end; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.bubble-who { max-width: 100%; margin-bottom: 2px; font-size: 12px; color: var(--text-2); overflow-wrap: anywhere; }
.bubble { padding: 8px 11px; border: 1px solid var(--line); border-radius: 3px 10px 10px 10px; background: var(--panel); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble-meta { margin-top: 2px; font-size: 12px; color: var(--text-3); }
.welcome h2 { font-size: 17px; font-weight: 600; color: var(--ink); }
.welcome p { color: var(--text-2); margin: 2px 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 32px; padding: 0 11px; border: 1px solid var(--line-2); border-radius: 16px; background: var(--panel); font-size: 13px; }
.cl-form { flex: none; }
.cl-form > .notice { border-top: 1px solid var(--red-line); border-bottom: 0; }
.composer { flex: none; display: flex; align-items: flex-end; gap: 8px; padding: 10px; background: var(--panel); border-top: 1px solid var(--line); }
.composer-input { flex: 1; min-width: 0; min-height: 38px; max-height: 120px; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: var(--r-m); background: var(--panel); resize: none; field-sizing: content; line-height: 1.5; }
.composer-input:focus-visible { outline-offset: 0; }
.composer-input:disabled { color: var(--text-3); cursor: not-allowed; }
.send-btn { width: 38px; min-height: 38px; padding: 0; }
.cl-actions { display: flex; justify-content: center; padding: 0 12px 8px; background: rgba(255, 252, 248, .42); }
.cl-actions:not(:has(> :not([hidden]))) { display: none; }

/* ———— 工作台 ———— */
.ws-body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.ws { flex: 1; min-height: 0; display: grid; grid-template-columns: 196px minmax(0, 1fr); }
.ws-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ws-top { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; padding: 8px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.ws-top-title { min-width: 0; }
.ws-top h1 { font-size: 17px; font-weight: 600; line-height: 1.35; color: var(--ink); }
.ws-top p { color: var(--text-2); font-size: 12px; }
.ws-top-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.ws-status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.ws-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: 264px minmax(0, 1fr) 280px; grid-template-rows: minmax(0, 1fr); }
.rail { position: relative; z-index: 20; display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 14px 10px 10px; background: var(--ink); color: var(--on-ink-2); }
.rail :focus-visible { outline-color: #9fe3c6; }
.rail-brand { display: flex; align-items: center; gap: 9px; padding: 0 6px; margin-bottom: 18px; }
.rail-brand .brand-mark { width: 30px; height: 30px; display: block; }
.rail-brand-text strong { display: block; color: #fff; font: 600 15px/1.3 var(--latin); }
.rail-brand-text small, .rail-who small { display: block; color: var(--on-ink-2); font-size: 12px; line-height: 1.4; }
.rail-item { position: relative; display: flex; align-items: center; gap: 9px; min-height: 40px; padding: 0 10px; border-radius: var(--r-m); text-align: left; text-decoration: none; }
.rail-item:hover { background: var(--ink-2); color: #fff; }
.rail-item[aria-current="page"] { background: var(--ink-3); color: #fff; }
.rail-badge { margin-left: auto; min-width: 16px; padding: 0 4px; border-radius: 8px; background: var(--amber-dot); color: #231602; font: 600 11px/16px var(--latin); text-align: center; }
.rail-acct { position: relative; margin-top: auto; }
.acct-btn { display: flex; align-items: center; gap: 9px; width: 100%; padding: 6px; border-radius: var(--r-m); }
.rail-who { min-width: 0; }
.rail-who strong { display: block; color: #fff; font-weight: 500; line-height: 1.35; }
.avatar { position: relative; display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--ink-3); color: #fff; }

.queue { display: flex; flex-direction: column; min-height: 0; background: var(--panel-2); border-right: 1px solid var(--line); }
.queue-head { flex: none; padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.queue-head h2 { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.search { position: relative; }
.search .ic { position: absolute; left: 9px; top: 9px; width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 30px; min-height: 34px; font-size: 13px; }
.queue-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 6px; }
.queue-group + .queue-group { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.queue-title { display: flex; align-items: center; gap: 6px; padding: 4px 10px; color: var(--text-2); font-size: 12px; font-weight: 600; }
.queue-title:focus { outline: none; }
.count { min-width: 18px; padding: 0 5px; border-radius: 9px; background: #ebe8e1; color: var(--text); font-size: 11px; line-height: 18px; text-align: center; }
.q-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 8px; width: 100%; padding: 9px 10px; border: 1px solid transparent; border-radius: var(--r-m); text-align: left; }
.q-item:hover:not(:disabled) { background: #f1efe9; }
.q-item:disabled { color: var(--text-3); }
.q-item[aria-current="true"] { background: var(--panel); border-color: var(--line-2); box-shadow: inset 3px 0 0 var(--green); }
.q-code { font: 600 14px/1.5 var(--latin); overflow-wrap: anywhere; }
.q-action { align-self: center; color: var(--green-d); font-size: 13px; font-weight: 500; }
.q-src { grid-column: 1 / -1; font-size: 12px; color: var(--text-2); }
.q-empty { padding: 18px; text-align: center; color: var(--text-2); font-size: 13px; }

.center { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); }
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-top { flex: none; display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.chat-title { flex: 1; min-width: 0; }
.chat-title h2 { font-size: 15px; font-weight: 600; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title h2:focus { outline: none; }
.chat-title p { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.chat-actions { display: flex; gap: 6px; flex: none; }
.only-narrow, .only-drawer { display: none; }
/* 账本式消息：左侧时间槽对齐，便于快速回溯 */
.ledger { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 0; background: var(--panel); }
.lg-row { display: grid; grid-template-columns: 62px minmax(0, 1fr); padding: 5px 20px 5px 0; }
.lg-time { padding-top: 1px; padding-right: 12px; color: var(--text-3); font-size: 12px; text-align: right; }
.lg-main { padding-left: 12px; border-left: 2px solid var(--line); max-width: 680px; }
.lg-row.me .lg-main { border-left-color: var(--green); }
.lg-who { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); }
.lg-row.me .lg-who { color: var(--green-d); }
.lg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.ws-composer { position: relative; flex: none; padding: 10px 16px 12px; border-top: 1px solid var(--line); }
.ws-composer .composer-input { width: 100%; min-height: 62px; max-height: 180px; display: block; }
.ws-composer-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.kbd-hint { flex: 1; color: var(--text-3); font-size: 12px; }
.state-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--canvas); overflow-y: auto; }
.state-card { width: min(420px, calc(100% - 32px)); margin: auto; padding: 22px; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--panel); box-shadow: var(--shadow); }
.state-card .ic { width: 24px; height: 24px; margin-bottom: 8px; color: var(--text-3); }
.state-card h2 { font-size: 17px; font-weight: 600; }
.state-card p { margin-top: 4px; color: var(--text-2); }
.kv { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.kv dt { color: var(--text-2); }
.kv dd { overflow-wrap: anywhere; }

.ctx { display: flex; flex-direction: column; min-height: 0; background: var(--panel-2); border-left: 1px solid var(--line); }
.ctx-head { flex: none; display: flex; align-items: center; justify-content: space-between; min-height: 58px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.ctx-head h2 { font-size: 15px; font-weight: 600; }
.ctx-body { flex: 1; min-height: 0; overflow-y: auto; }
.ctx-sec { padding: 12px 14px; }
.ctx-sec .kv:last-child { border-bottom: 0; }
.ctx-empty { padding: 28px 18px; color: var(--text-2); font-size: 13px; text-align: center; }
.ctx-scrim { display: none; }

.gate { flex: 1; min-height: 0; display: grid; place-items: center; padding: 20px; background: var(--ink); overflow-y: auto; }
.gate-status { color: var(--on-ink); text-align: center; }
.login-card { margin: 0; }
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-brand .brand-mark { width: 30px; height: 30px; flex: none; }
.login-brand h1 { font-size: 17px; font-weight: 600; color: var(--ink); }
.login-status { padding: 6px 10px; border-radius: var(--r-m); background: var(--green-bg); color: var(--green-d) !important; font-size: 13px; }
.login-form { margin-top: 14px; }
.login-form .input { margin-bottom: 12px; }
.login-form .field-error { margin: 0 0 12px; }
.login-form .btn { width: 100%; }

/* ———— 响应式 ———— */
@media (max-width: 1180px) {
  .ws { grid-template-columns: 64px minmax(0, 1fr); }
  .ws-grid { grid-template-columns: 260px minmax(0, 1fr); }
  .rail { align-items: center; padding: 12px 0; }
  .rail-brand { display: block; padding: 0; margin-bottom: 12px; }
  .rail-brand-text, .rail-who { display: none; }
  .rail-item { flex-direction: column; justify-content: center; gap: 2px; width: 54px; min-height: 0; padding: 7px 0 5px; font-size: 11px; line-height: 1.3; }
  .rail-badge { position: absolute; top: 2px; right: 6px; margin: 0; }
  .acct-btn { width: auto; padding: 0; }
  .only-drawer { display: inline-flex; }
  .ctx { position: fixed; z-index: 40; top: 0; right: 0; bottom: 0; width: min(320px, 100%); visibility: hidden; transform: translateX(100%); transition: transform .18s ease-out, visibility .18s; box-shadow: var(--shadow-l); }
  .ctx.is-open { visibility: visible; transform: none; }
  .ctx-scrim.is-open { display: block; position: fixed; z-index: 35; inset: 0; background: rgba(16, 48, 42, .35); }
}
@media (max-width: 720px) {
  .cl-stage { padding: 0; align-items: stretch; }
  .cl-window { max-width: none; max-height: none; border: 0; border-radius: 0; box-shadow: none; }
  .composer-input, .input { font-size: 16px; }

  .ws { display: flex; flex-direction: column; }
  .ws-main { flex: 1; }
  .ws-grid { display: flex; flex-direction: column; }
  .ws-top { min-height: 44px; padding: 6px 12px; }
  .ws-top h1 { font-size: 15px; }
  .ws-top p, .queue-head h2 { display: none; }
  .ws[data-view="chat"] .ws-top { display: none; }
  .rail { flex: none; flex-direction: row; gap: 6px; padding: 6px 10px; }
  .rail-brand { margin: 0 6px 0 0; }
  .rail-item { flex-direction: row; gap: 5px; width: auto; min-height: 36px; padding: 0 9px; font-size: 13px; }
  .rail-badge { position: static; }
  .rail-acct { margin: 0 0 0 auto; }
  .queue { flex: 1; min-height: 0; border-right: 0; }
  .q-item { padding: 11px 10px; }
  .center { flex: 1; min-height: 0; }
  .ws[data-view="list"] .center { display: none; }
  .ws[data-view="chat"] .rail, .ws[data-view="chat"] .queue { display: none; }
  .only-narrow { display: inline-flex; }
  .chat-top { padding: 6px 8px; gap: 4px; }
  .chat-actions .btn { width: 38px; min-height: 38px; padding: 0; }
  .chat-actions .btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .icon-only-m { width: 38px; min-height: 38px; padding: 0; }
  .lg-row { grid-template-columns: 50px minmax(0, 1fr); padding-right: 12px; }
  .lg-time { padding-right: 8px; }
  .lg-main { padding-left: 9px; }
  .ws-composer { padding: 8px; }
  .kbd-hint { display: none; }
  .ws-composer-row { justify-content: flex-end; }
  .ctx { width: 100%; }
  .btn { min-height: 38px; }
}

/* ———— 工作台：消息归属、列表摘要、访客来源 ———— */
.lg-row.me { grid-template-columns: minmax(0, 1fr) 62px; padding: 5px 0 5px 20px; }
.lg-row.me .lg-time { order: 2; padding-right: 0; padding-left: 10px; text-align: left; }
.lg-row.me .lg-main { order: 1; justify-self: end; min-width: 0; padding: 0 12px 0 0; border-left: 0; border-right: 2px solid var(--green); }
.lg-row.me .lg-who { text-align: right; }
.lg-row[data-relation="other_staff"] .lg-main { border-left-color: var(--amber-dot); }
.lg-row[data-relation="other_staff"] .lg-who { color: var(--amber); }

.q-preview { grid-column: 1 / -1; display: block; min-width: 0; overflow: hidden; margin-top: 2px; color: var(--text-2); font-size: 12px; line-height: 1.5; white-space: nowrap; text-overflow: ellipsis; }
.q-preview[data-state="pending"] { color: var(--text-3); }
.q-preview[data-state="denied"] { color: var(--amber); }
.q-preview[data-state="bad"] { color: var(--red); }
.q-preview-who { color: var(--green-d); font-weight: 500; }

.src { min-width: 0; font-size: 12px; line-height: 1.5; color: var(--text-2); }
.src-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.src-title { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.src-note { color: var(--text-3); }
.src-fields { display: flex; flex-wrap: wrap; gap: 0 12px; }
.src-field { min-width: 0; overflow-wrap: anywhere; }
.src-k { margin-right: 4px; color: var(--text-3); }
.src-v { color: var(--text); }
.src[data-state="bad"] .src-state { color: var(--red); }
.src[data-state="denied"] .src-state, .src[data-state="error"] .src-state { color: var(--amber); }
.src-strip { flex: 999 1 380px; max-height: 76px; overflow-y: auto; padding: 3px 10px; border-left: 2px solid var(--line); }
.chat-top { flex-wrap: wrap; }
.chat-title { flex: 1 1 200px; }
.src-lookup { border-top: 1px solid var(--line); }
.src-lookup h3 { font-size: 13px; font-weight: 600; }
.src-lookup-hint { color: var(--text-3); font-size: 12px; }
.src-lookup-form { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.src-lookup-form .input { flex: 1 1 130px; width: auto; min-width: 0; min-height: 30px; padding: 4px 8px; font-size: 13px; }
.src-card { margin-top: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--panel); }
.src-card .src-fields { flex-direction: column; }

@media (max-width: 1180px) {
  .src-strip { order: 3; flex: 1 0 100%; padding: 2px 0 0; border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 720px) {
  .lg-row.me { grid-template-columns: minmax(0, 1fr) 50px; padding: 5px 0 5px 12px; }
  .lg-row.me .lg-time { padding-left: 6px; padding-right: 0; }
  .lg-row.me .lg-main { padding: 0 9px 0 0; }
  .src-strip { max-height: 58px; padding: 2px 4px 0; }
  .src-lookup-form .input { font-size: 16px; min-height: 38px; }
}
@media (max-height: 520px) {
  .src-strip { max-height: 24px; }
}

/* ———— 访客窗口 · 暖色液态玻璃（只覆盖 .cl-body，工作台不受影响） ———— */
.cl-body {
  --ink: #3b2417; --on-ink: #3b2417; --on-ink-2: #6b4632;
  --canvas: #f4dfcd; --panel: rgba(255, 250, 245, .72); --panel-2: rgba(255, 246, 238, .55);
  --line: rgba(122, 74, 44, .16); --line-2: rgba(122, 74, 44, .3);
  --text: #3b2417; --text-2: #6b4632; --text-3: #7a5238;
  --green: #8a4420; --green-d: #8a4420; --green-bg: #f8e5d3;
  --amber: #7f4a00; --red: #9f2c22; --red-d: #8a241b;
  --copper: #a4552a; --copper-d: #8a4420; --ok-ink: #3f6b3a;
  --glass-edge: rgba(255, 255, 255, .72);
  --r-s: 8px; --r-m: 14px; --r-l: 20px;
  --shadow: 0 2px 6px rgba(122, 74, 44, .08), 0 14px 32px rgba(122, 74, 44, .12);
  --shadow-l: 0 4px 12px rgba(122, 74, 44, .1), 0 32px 72px rgba(122, 74, 44, .24);
  background:
    radial-gradient(46% 52% at 12% 16%, rgba(255, 244, 232, .95), transparent 72%),
    radial-gradient(42% 50% at 88% 12%, rgba(240, 190, 150, .62), transparent 72%),
    radial-gradient(52% 58% at 76% 92%, rgba(226, 160, 118, .5), transparent 74%),
    radial-gradient(44% 50% at 18% 90%, rgba(250, 214, 186, .85), transparent 72%),
    linear-gradient(150deg, #f8e9db, #eecdb4);
}
/* 单窗高度取舞台内容盒的 100%，自动扣除留白；视口矮于下限时由舞台滚动，auto 外边距避免顶部被裁 */
.cl-body .cl-stage { --cl-py: clamp(12px, 4vh, 40px); --cl-px: clamp(12px, 4vw, 40px); overflow-y: auto; padding: max(var(--cl-py), env(safe-area-inset-top)) max(var(--cl-px), env(safe-area-inset-right)) max(var(--cl-py), env(safe-area-inset-bottom)) max(var(--cl-px), env(safe-area-inset-left)); }
.cl-body .cl-window { position: relative; max-width: 540px; height: 100%; min-height: 280px; max-height: 760px; margin: auto; background: rgba(255, 247, 240, .58); border: 1px solid var(--glass-edge); border-radius: 28px; box-shadow: var(--shadow-l), inset 0 1px 0 rgba(255, 255, 255, .85); -webkit-backdrop-filter: blur(22px) saturate(135%); backdrop-filter: blur(22px) saturate(135%); }
/* 空间不足时消息区保底，表单自身滚动，输入框不会被窗口裁掉 */
.cl-body .timeline-wrap { min-height: 96px; }
.cl-body .cl-form { flex: 0 1 auto; min-height: 0; overflow-y: auto; }

.cl-body .brand-mark { border-radius: 50%; }
.cl-body .brand-mark rect { fill: var(--copper); }
.cl-body .btn { border-radius: 999px; background: rgba(255, 250, 245, .78); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7); }
.cl-body .btn:hover:not(:disabled) { background: #fffaf5; border-color: var(--copper); }
.cl-body .btn:disabled { color: #806450; background: rgba(233, 211, 194, .7); border-color: var(--line); box-shadow: none; }
.cl-body .btn-primary { background: linear-gradient(180deg, #ad5c30, var(--copper)); border-color: var(--copper-d); color: #fff; box-shadow: 0 6px 14px rgba(138, 68, 32, .24), inset 0 1px 0 rgba(255, 255, 255, .28); }
.cl-body .btn-primary:hover:not(:disabled) { background: var(--copper-d); border-color: var(--copper-d); }
.cl-body .notice { background: rgba(255, 248, 241, .6); }
.cl-body .notice.wait { background: rgba(252, 236, 208, .9); }
.cl-body .notice.bad { background: rgba(251, 232, 228, .92); }
.cl-body .notice.ok { background: rgba(234, 240, 217, .92); border-color: #cfdcae; color: var(--ok-ink); }

.cl-body .cl-head { padding: 14px 16px; background: rgba(255, 252, 248, .36); border-bottom: 1px solid var(--line); box-shadow: inset 0 -1px 0 rgba(255, 255, 255, .4); }
.cl-body .cl-head .brand-mark { width: 38px; height: 38px; box-shadow: 0 4px 10px rgba(138, 68, 32, .24); }
.cl-body .cl-log { padding: 18px 16px; gap: 12px; background: transparent; }
.cl-body .cl-log:focus-visible { outline-offset: -3px; border-radius: 12px; }
.cl-body .bubble { padding: 9px 13px; border-color: var(--glass-edge); border-radius: 6px 18px 18px 18px; background: rgba(255, 252, 248, .84); box-shadow: 0 2px 8px rgba(122, 74, 44, .08); }
.cl-body .me .bubble { border-color: var(--copper-d); border-radius: 18px 6px 18px 18px; background: linear-gradient(170deg, #a95c30, #8f4821); color: #fff; }

/* 嵌套玻璃卡片 */
.cl-body .welcome { padding: 16px; border: 1px solid var(--glass-edge); border-radius: var(--r-l); background: rgba(255, 251, 247, .62); box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .8); }
.cl-body .welcome p { margin-bottom: 0; }

.cl-body .composer { align-items: flex-end; padding: 10px 12px; background: rgba(255, 252, 248, .42); border-top-color: var(--line); }
.cl-body .composer-input { min-height: 42px; padding: 9px 14px; border-radius: 21px; background: rgba(255, 253, 251, .92); box-shadow: inset 0 1px 2px rgba(122, 74, 44, .08); }
.cl-body .send-btn { width: 42px; min-height: 42px; }

@media (max-height: 600px) {
  .cl-body .cl-stage { --cl-py: 8px; }
  .cl-body .cl-head { padding-top: 8px; padding-bottom: 8px; }
}
@media (max-width: 720px) {
  .cl-body .cl-stage { --cl-py: 8px; --cl-px: 8px; }
  .cl-body .cl-window { max-height: none; border-radius: 22px; box-shadow: var(--shadow); }
  .cl-body .cl-log { padding: 14px 12px; }
  .cl-body .composer { padding: 8px; }
}

/* ———— 生命周期：访客窗内状态与过往咨询 ———— */
.cl-actions { flex-wrap: wrap; gap: 6px; }
.cl-form[data-readonly="true"] .composer { display: none; }
.cl-form[data-readonly="true"] .cl-actions { padding-top: 8px; }
.cl-history { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; min-height: 0; background: rgba(255, 248, 241, .97); }
.cl-history-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 16px; border-bottom: 1px solid var(--line); }
.cl-history-head h2 { font-size: 14px; font-weight: 600; }
.cl-history-list { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 10px; }
.cl-history-item { display: block; width: 100%; min-height: 36px; padding: 6px 8px; border-radius: var(--r-s); font-size: 13px; text-align: left; overflow-wrap: anywhere; }
.cl-history-item:hover { background: rgba(255, 252, 248, .9); }
.cl-history-item[aria-current="true"] { box-shadow: inset 3px 0 0 var(--copper); }

/* ———— 工作台：留言标记、转接与结束、历史 ———— */
select.input { font: inherit; color: inherit; }
.rail-item { width: 100%; color: inherit; }
.q-tag { display: inline-block; margin-right: 6px; padding: 0 6px; border: 1px solid var(--amber-line); border-radius: var(--r-s); background: var(--amber-bg); color: var(--amber); font-size: 11px; font-weight: 600; line-height: 16px; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--red-d); border-color: var(--red-d); }
.dialog { width: min(400px, calc(100vw - 24px)); max-height: calc(100dvh - 16px); padding: 18px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--panel); color: var(--text); box-shadow: var(--shadow-l); }
.dialog::backdrop { background: rgba(16, 48, 42, .35); }
.dialog h2 { font-size: 15px; font-weight: 600; }
.dialog p { margin-top: 4px; color: var(--text-2); font-size: 13px; }
.dialog .field-label { margin-top: 10px; }
.dialog .field-error { color: var(--red); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.hist { flex: 1; min-height: 0; display: grid; grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.hist-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 6px; }
.queue-head h2:focus { outline: none; }
.hist-filter { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2px 8px; }
.hist-filter .field-label { grid-row: 1; margin: 0; font-size: 12px; }
.hist-filter .input { grid-row: 2; min-width: 0; min-height: 32px; padding: 3px 6px; font-size: 13px; }
.hist-filter .btn { grid-row: 3; margin-top: 6px; }
.hist-more { display: flex; width: 100%; margin-top: 6px; }
.hist .chat-actions .btn { width: auto; padding: 0 9px; }
#staff-history-meta { display: block; overflow-wrap: anywhere; }

@media (max-width: 720px) {
  .rail-item { width: auto; }
  .ws-top { flex-wrap: wrap; gap: 4px 10px; }
  .ws-top-actions { flex-wrap: wrap; gap: 6px; }
  .hist { display: flex; flex-direction: column; }
  .hist-side { flex: 1; border-right: 0; }
  .hist[data-view="list"] .center { display: none; }
  .hist[data-view="detail"] .hist-side { display: none; }
  .hist .center { flex: 1; min-height: 0; }
  .ws[data-view] .hist[data-view="detail"] .center { display: flex; }
  .hist .chat-actions .btn { min-height: 38px; font-size: 13px; }
  .dialog select.input { font-size: 16px; }
}
@media (max-width: 1180px) {
  .rail-item { width: 54px; }
}
@media (max-width: 720px) {
  .rail-item { width: auto; }
}
@media (max-height: 520px) {
  .ws-top-title { display: none; }
  .queue-head { padding: 6px 10px; }
  .hist-filter .input { min-height: 30px; }
}

/* ———— 账号：个人资料弹层与管理后台，沿用工作台的墨绿与卡片语言 ———— */
.ad-status { margin-top: 8px; color: var(--text-2); font-size: 13px; overflow-wrap: anywhere; }
.ad-status:empty { display: none; }
.ad-status[data-state="ok"] { color: var(--green-d); }
.ad-status[data-state="bad"] { color: var(--red); }
.dialog input.input:disabled { background: #f1efea; color: var(--text-3); cursor: not-allowed; }
.login-form .btn + .btn { margin-top: 8px; }
.ad-body { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.ad-top { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px; background: var(--ink); color: var(--on-ink-2); }
.ad-top :focus-visible { outline-color: #9fe3c6; }
.ad-brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.ad-brand .brand-mark { width: 30px; height: 30px; flex: none; }
.ad-brand strong { display: block; color: #fff; font: 600 15px/1.3 var(--latin); }
.ad-brand small { display: block; font-size: 12px; line-height: 1.4; }
.ad-main { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; width: 100%; max-width: 1120px; margin: 0 auto; padding: 20px; }
.ad-card { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--panel); box-shadow: var(--shadow); }
.ad-card h1, .ad-card h2 { color: var(--ink); font-size: 15px; font-weight: 600; }
.ad-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ad-hint { margin-top: 4px; color: var(--text-2); font-size: 13px; }
.ad-table-wrap { margin-top: 10px; overflow-x: auto; }
.ad-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ad-table th, .ad-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; overflow-wrap: anywhere; }
.ad-table th { color: var(--text-2); font-weight: 600; white-space: nowrap; }
.ad-table tbody tr:last-child td { border-bottom: 0; }
.ad-muted { color: var(--text-3); }
.ad-table .ad-action { white-space: nowrap; overflow-wrap: normal; }
.ad-disable-account { color: var(--text); overflow-wrap: anywhere; }
#admin-disable-dialog:focus { outline: none; }
.ad-form { margin-top: 12px; }
.ad-form .input { margin-bottom: 10px; }
.ad-form .ad-status { margin: 0 0 10px; }
.ad-form .input + .ad-hint, .ad-form .field-error { margin: -6px 0 10px; }
.ad-form .input[aria-invalid="true"] { border-color: var(--red); }
.ad-form .btn { width: 100%; }
.ad-reverify { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.ad-customers { grid-column: 1 / -1; }
.ad-customers h3 { margin-top: 12px; color: var(--ink); font-size: 14px; font-weight: 600; }
.ad-customers h3:focus { outline: none; }
.ad-customers .ad-table { min-width: 520px; }
.ad-customers td.num { white-space: nowrap; overflow-wrap: normal; }
.ad-customers td.ad-customer-body { min-width: 16em; white-space: pre-wrap; }
.ad-customer-identity { margin-top: 10px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--panel-2); }
.ad-customer-identity .kv { border-bottom: 0; }
.ad-customer-identity .kv + .kv { border-top: 1px solid var(--line); }

/* ———— 工作台：客户归属与内部备注，全部限定在 .internal 内 ———— */
.internal { border-top: 1px solid var(--line); }
.internal-history { flex: none; padding: 10px 16px; background: var(--panel-2); }
.internal-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 8px; }
.internal h3 { font-size: 13px; font-weight: 600; }
.internal h4 { margin: 10px 0 4px; color: var(--text-2); font-size: 12px; font-weight: 600; }
.internal-owner { padding: 0 8px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--panel); }
.internal-owner .kv:last-child { border-bottom: 0; }
.internal-empty { padding: 6px 0; color: var(--text-2); font-size: 13px; }
.internal-notes { max-height: min(36vh, 320px); overflow-y: auto; }
.internal-note { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.internal-note:last-child { border-bottom: 0; }
.internal-note-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 8px; color: var(--text-3); font-size: 12px; }
.internal-note-author { color: var(--text-2); font-weight: 500; overflow-wrap: anywhere; }
.internal-note-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.internal-form { margin-top: 10px; padding: 8px; border: 1px solid var(--amber-line); border-radius: var(--r-m); background: var(--amber-bg); }
.internal-form .composer-input { display: block; width: 100%; min-height: 62px; max-height: 160px; }
.internal-form-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.internal-count { color: var(--text-2); font-size: 12px; }
.internal-count[data-over="true"] { color: var(--red); }
@media (max-width: 860px) {
  .ad-main { grid-template-columns: minmax(0, 1fr); padding: 12px; }
  .ad-top { padding: 8px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
