:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #fff;
  --surface-soft: #f7f8fa;
  --ink: #17181a;
  --secondary: #656a73;
  --tertiary: #9298a2;
  --line: #e4e6ea;
  --line-strong: #d4d7dd;
  --blue: #1769e0;
  --blue-soft: #edf4ff;
  --green: #27875d;
  --green-soft: #eaf7f0;
  --amber: #a76712;
  --amber-soft: #fff5e5;
  --red: #b34646;
  --red-soft: #fff0f0;
  --shadow: 0 1px 2px rgba(22, 28, 38, .04), 0 8px 24px rgba(22, 28, 38, .05);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  --mono: "SF Mono", SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { min-width: 1180px; margin: 0; overflow: hidden; color: var(--ink); background: var(--bg); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(23, 105, 224, .25); outline-offset: 2px; }
.workspace { display: grid; grid-template-columns: 176px 318px minmax(500px, 1fr) 342px; height: 100vh; }
.rail { display: flex; flex-direction: column; min-width: 0; padding: 16px 12px; color: #fff; background: #17191e; }
.rail-brand { display: flex; min-height: 42px; align-items: center; gap: 10px; padding: 0 8px; color: #fff; font-size: 13px; font-weight: 750; text-decoration: none; }
.rail-brand-mark { display: grid; flex: 0 0 auto; width: 36px; height: 36px; place-items: center; border-radius: 11px; color: #fff; background: linear-gradient(145deg, #2581ff, #1760cf); font-size: 12px; font-weight: 800; box-shadow: 0 7px 18px rgba(23, 105, 224, .28); }
.rail-nav { display: grid; gap: 6px; margin-top: 28px; }
.rail-item { display: flex; width: 100%; min-height: 42px; align-items: center; padding: 0 12px; border: 0; border-radius: 10px; color: #aeb3bd; background: transparent; font-size: 12px; font-weight: 650; text-decoration: none; transition: .18s ease; }
.rail-item:hover { color: #fff; background: #252932; }
.rail-item.is-active { color: #fff; background: #2a2e36; box-shadow: inset 3px 0 0 #2581ff; }
.rail-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-identity { display: flex; align-items: center; gap: 9px; margin-top: auto; padding: 10px 8px 0; border-top: 1px solid #30343d; color: #d6d8dd; font-size: 11px; }
.agent-avatar { display: grid; flex: 0 0 auto; width: 34px; height: 34px; place-items: center; border: 2px solid #40444d; border-radius: 50%; color: #fff; background: #4568dc; font-weight: 750; }
.mobile-workbench-tabs, .mobile-surface-nav { display: none; }
.inbox-panel, .conversation-panel, .context-panel { min-width: 0; min-height: 0; background: var(--surface); }
.inbox-panel { display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.panel-header { flex: 0 0 auto; min-height: 75px; border-bottom: 1px solid var(--line); }
.inbox-header { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; }
.eyebrow { margin: 0 0 2px; color: var(--tertiary); font: 650 9px/1.2 var(--mono); letter-spacing: .13em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 19px; letter-spacing: -.02em; }
.demo-chip, .verified-chip { padding: 3px 7px; border-radius: 999px; color: var(--amber); background: var(--amber-soft); font-size: 10px; font-weight: 700; }
.queue-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 12px 14px 8px; padding: 3px; border-radius: 10px; background: var(--surface-soft); }
.queue-tab { min-height: 34px; padding: 0 6px; border: 0; border-radius: 8px; color: var(--secondary); background: transparent; font-size: 12px; font-weight: 650; }
.queue-tab span { color: var(--tertiary); font: 10px var(--mono); }
.queue-tab.is-active { color: var(--ink); background: #fff; box-shadow: 0 1px 4px rgba(20, 25, 35, .08); }
.search-box { display: flex; align-items: center; gap: 7px; margin: 0 14px 10px; padding: 0 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--tertiary); background: var(--surface-soft); }
.search-box input { width: 100%; height: 36px; border: 0; outline: 0; background: transparent; font-size: 12px; }
.conversation-list { flex: 1; margin: 0; padding: 0 8px; overflow-y: auto; list-style: none; }
.conversation-item { display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; margin: 3px 0; padding: 12px 10px; border: 1px solid transparent; border-radius: 12px; background: transparent; }
.conversation-item.is-selected { border-color: #d9e7fb; background: var(--blue-soft); }
.queue-avatar { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 50%; color: #fff; background: linear-gradient(145deg, #64748b, #475569); font-weight: 700; }
.queue-copy { min-width: 0; }
.queue-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.queue-row strong { font-size: 13px; }
.queue-row time { color: var(--tertiary); font: 9px var(--mono); }
.queue-subject { margin: 3px 0 1px; overflow: hidden; color: var(--ink); font-size: 12px; font-weight: 620; text-overflow: ellipsis; white-space: nowrap; }
.queue-preview { margin: 0; overflow: hidden; color: var(--secondary); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.queue-badge { align-self: start; min-width: 9px; height: 9px; margin-top: 4px; border-radius: 50%; background: var(--blue); }
.inbox-footer { padding: 12px 16px; border-top: 1px solid var(--line); color: var(--secondary); font-size: 11px; }
.presence-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #32c876; }
.conversation-panel { display: flex; flex-direction: column; }
.conversation-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; }
.conversation-heading { display: flex; align-items: center; gap: 10px; }
.customer-avatar { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 50%; color: #fff; background: #65758b; font-weight: 750; }
.conversation-heading h2 { margin: 0; font-size: 15px; }
.conversation-heading p { margin: 2px 0 0; color: var(--secondary); font-size: 11px; }
.conversation-actions { display: flex; align-items: center; gap: 7px; }
.status-pill, .sla-status, .memory-status { display: inline-flex; align-items: center; min-height: 26px; padding: 2px 9px; border-radius: 999px; color: var(--secondary); background: var(--surface-soft); font-size: 11px; font-weight: 650; }
.status-pill[data-status="waiting"] { color: var(--amber); background: var(--amber-soft); }
.status-pill[data-status="active"] { color: var(--green); background: var(--green-soft); }
.status-pill[data-status="resolved"] { color: var(--secondary); background: #eef0f3; }
.conversation-actions button, .reply-actions button { min-height: 35px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--ink); background: #fff; font-size: 12px; font-weight: 650; }
#assign-button, #send-reply-button { border-color: var(--blue); color: #fff; background: var(--blue); }
.handoff-banner { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; margin: 12px 18px 0; padding: 11px 13px; border: 1px solid #cfe0f8; border-radius: 12px; background: var(--blue-soft); }
.handoff-icon { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 9px; color: var(--blue); background: #fff; font: 750 11px var(--mono); }
.handoff-banner strong { font-size: 12px; }
.handoff-banner p { margin: 2px 0 0; color: var(--secondary); font-size: 11px; }
.handoff-priority { color: var(--amber); font-size: 10px; font-weight: 700; }
.message-stream { flex: 1; min-height: 0; margin: 0; padding: 22px 24px; overflow-y: auto; background: linear-gradient(180deg, #fff, #fbfcfd); list-style: none; }
.message-row { display: grid; grid-template-columns: 30px minmax(0, 520px); gap: 9px; align-items: end; margin: 12px 0; }
.message-row.customer { grid-template-columns: minmax(0, 520px); justify-content: end; }
.message-row.system { display: flex; justify-content: center; }
.message-avatar { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 50%; color: #fff; background: #65758b; font-size: 10px; font-weight: 700; }
.message-row.agent .message-avatar { background: #4568dc; }
.message-bubble { padding: 10px 12px; border: 1px solid var(--line); border-radius: 5px 15px 15px 15px; background: #fff; box-shadow: 0 2px 8px rgba(20, 25, 35, .04); }
.message-row.customer .message-bubble { border-color: #1f70df; border-radius: 15px 5px 15px 15px; color: #fff; background: var(--blue); }
.message-meta { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 3px; color: var(--tertiary); font-size: 9px; }
.message-row.customer .message-meta { color: rgba(255,255,255,.72); }
.message-text { margin: 0; font-size: 13px; line-height: 1.55; white-space: pre-wrap; }
.system-note { padding: 5px 10px; border-radius: 999px; color: var(--secondary); background: var(--surface-soft); font-size: 10px; }
.reply-composer { flex: 0 0 auto; padding: 10px 18px 14px; border-top: 1px solid var(--line); background: #fff; }
.reply-context, .reply-actions { display: flex; align-items: center; justify-content: space-between; color: var(--tertiary); font-size: 10px; }
.reply-context { margin-bottom: 7px; }
.reply-context span:first-child { color: var(--green); font-weight: 700; }
.reply-composer textarea { width: 100%; min-height: 74px; padding: 10px 12px; resize: none; border: 1px solid var(--line-strong); border-radius: 11px; outline: 0; background: var(--surface-soft); font-size: 13px; }
.reply-composer textarea:focus { border-color: var(--blue); background: #fff; }
.reply-actions { margin-top: 7px; }
.context-panel { padding: 0 14px 18px; overflow-y: auto; border-left: 1px solid var(--line); background: var(--surface-soft); }
.context-top { position: sticky; z-index: 2; top: 0; display: flex; align-items: center; justify-content: space-between; min-height: 75px; background: var(--surface-soft); }
.context-top h2 { margin: 0; font-size: 17px; }
.context-links { display: grid; gap: 3px; text-align: right; }
.context-links a, .context-card a { color: var(--blue); font-size: 10px; font-weight: 650; text-decoration: none; }
.context-card { margin-bottom: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 2px 8px rgba(20,25,35,.025); }
.context-card-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; color: var(--secondary); font-size: 11px; font-weight: 700; }
.sla-status { min-height: 22px; color: var(--green); background: var(--green-soft); font-size: 9px; }
.sla-clock { display: block; margin-bottom: 7px; font: 700 23px var(--mono); letter-spacing: -.04em; }
.sla-track { height: 4px; overflow: hidden; border-radius: 999px; background: #edf0f3; }
.sla-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--green); transition: width .4s ease; }
.sla-card p, .knowledge-card p, .knowledge-card small { color: var(--secondary); }
.sla-card p { margin: 7px 0 0; font-size: 10px; }
.detail-list { display: grid; gap: 7px; margin: 0; }
.detail-list div { display: grid; grid-template-columns: 68px 1fr; gap: 8px; }
.detail-list dt { color: var(--tertiary); font-size: 10px; }
.detail-list dd { margin: 0; font-size: 11px; overflow-wrap: anywhere; }
.priority-control { display: flex; align-items: center; justify-content: space-between; margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--tertiary); font-size: 10px; }
.priority-control select { min-height: 30px; padding: 0 7px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); font-size: 11px; }
.verified-chip { color: var(--green); background: var(--green-soft); }
.knowledge-card strong { font-size: 12px; }
.knowledge-card p { margin: 3px 0; font-size: 10px; }
.knowledge-card small { display: block; line-height: 1.5; }
.memory-context p { margin: 0 0 9px; font-size: 11px; line-height: 1.55; }
.memory-context > div:last-child { display: flex; align-items: center; gap: 7px; color: var(--tertiary); font-size: 9px; }
.memory-status { min-height: 21px; color: var(--green); background: var(--green-soft); font-size: 9px; }
.toast { position: fixed; z-index: 50; right: 20px; bottom: 20px; max-width: 360px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: rgba(255,255,255,.96); box-shadow: var(--shadow); font-size: 12px; }
.toast[data-tone="error"] { color: var(--red); border-color: #f1caca; background: var(--red-soft); }
@media (max-width: 1280px) { .workspace { grid-template-columns: 164px 286px minmax(480px, 1fr) 316px; } }
@media (max-width: 760px) {
  html, body { width: 100%; height: 100%; min-height: 100%; }
  body { min-width: 0; overflow: hidden; padding-bottom: calc(72px + env(safe-area-inset-bottom)); background: #f4f5f7; }
  .workspace { position: relative; display: block; width: 100%; height: calc(100vh - 72px - env(safe-area-inset-bottom)); height: calc(100dvh - 72px - env(safe-area-inset-bottom)); min-height: 0; padding-top: 104px; overflow: hidden; background: #fff; }
  .rail { display: none; }
  .mobile-workbench-tabs { position: absolute; z-index: 30; top: 0; right: 0; left: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; height: 104px; padding: calc(12px + env(safe-area-inset-top)) 14px 10px; border-bottom: 1px solid var(--line); background: rgba(247,248,250,.96); backdrop-filter: blur(20px); }
  .mobile-workbench-tabs::before { grid-column: 1 / -1; content: "客服工作台"; color: var(--ink); font-size: 18px; font-weight: 750; }
  .mobile-workbench-tabs button { min-height: 36px; border: 0; border-radius: 9px; color: var(--secondary); background: transparent; font-size: 12px; font-weight: 650; }
  .mobile-workbench-tabs button.is-active { color: var(--blue); background: #fff; box-shadow: 0 1px 5px rgba(20,25,35,.09); }
  .inbox-panel, .conversation-panel, .context-panel { position: absolute; inset: 104px 0 0; display: none; width: 100%; height: calc(100% - 104px); min-height: 0; border: 0; background: #fff; }
  .workspace[data-mobile-view="inbox"] .inbox-panel { display: flex; }
  .workspace[data-mobile-view="conversation"] .conversation-panel { display: flex; }
  .workspace[data-mobile-view="context"] .context-panel { display: block; }
  .inbox-panel { flex-direction: column; }
  .panel-header { min-height: 68px; }
  .inbox-header { padding: 12px 15px; }
  .conversation-list { flex: 1; min-height: 0; max-height: none; padding: 0 8px 12px; overflow-y: auto; }
  .inbox-footer { display: block; }
  .conversation-header { flex-wrap: wrap; gap: 8px; min-height: 104px; padding: 10px 14px; }
  .conversation-heading { min-width: 0; }
  .conversation-heading > div { min-width: 0; }
  .conversation-actions { width: 100%; flex-wrap: wrap; }
  .conversation-actions button { flex: 1 1 auto; }
  .handoff-banner { grid-template-columns: auto 1fr; margin: 9px 12px 0; }
  .handoff-priority { grid-column: 2; }
  .message-stream { flex: 1; min-height: 0; max-height: none; padding: 14px 13px; }
  .message-row, .message-row.customer { grid-template-columns: 30px minmax(0, 1fr); }
  .message-row.customer { grid-template-columns: minmax(0, 88%); }
  .reply-composer { padding: 9px 12px 12px; }
  .reply-context, .reply-actions { gap: 8px; }
  .reply-actions > span { max-width: 55%; }
  .context-panel { padding: 0 12px 22px; overflow-y: auto; background: var(--surface-soft); }
  .context-top { position: sticky; min-height: 64px; }
  .context-links { display: flex; gap: 10px; }
  .mobile-surface-nav { position: fixed; z-index: 90; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(3, 1fr); height: calc(72px + env(safe-area-inset-bottom)); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(250,250,252,.94); box-shadow: 0 -8px 24px rgba(20,25,35,.06); backdrop-filter: blur(24px); }
  .mobile-surface-nav a { display: grid; place-items: center; align-content: center; gap: 3px; border-radius: 14px; color: var(--tertiary); text-decoration: none; }
  .mobile-surface-nav span { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 9px; background: #eceef2; font-size: 11px; font-weight: 750; }
  .mobile-surface-nav strong { font-size: 10px; font-weight: 650; }
  .mobile-surface-nav a.is-active { color: var(--blue); background: var(--blue-soft); }
  .mobile-surface-nav a.is-active span { color: #fff; background: var(--blue); }
  .toast { right: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); left: 12px; max-width: none; }
}
