:root {
  --paper: #f4f6f5;
  --surface: #fff;
  --ink: #202a28;
  --muted: #6f7a77;
  --line: #dce2df;
  --line-strong: #c8d0cc;
  --red: #9e312d;
  --red-dark: #78231f;
  --pine: #3e6c5e;
  --pine-soft: #e9f0ed;
  --amber: #a66a21;
  --blue: #3c6178;
  --shadow: 0 8px 28px rgba(27, 43, 38, 0.08);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
}
button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}
button {
  cursor: pointer;
}
.app-shell {
  display: grid;
  grid-template-columns: 72px minmax(280px, 330px) minmax(440px, 1fr) 292px;
  height: 100vh;
  min-height: 650px;
  overflow: hidden;
}
.app-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 8px;
  background: #26322f;
  color: #fff;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: #fff;
  background: var(--red);
  text-decoration: none;
  font-family: "STSong", "Songti SC", serif;
  font-size: 22px;
  border: 1px solid rgba(255, 255, 255, 0.24);
}
.rail-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 7px;
  margin-top: 32px;
}
.rail-button {
  display: grid;
  place-items: center;
  width: 52px;
  min-height: 54px;
  padding: 6px 2px;
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  color: #aeb9b5;
}
.rail-button span {
  font-family: "STSong", "Songti SC", serif;
  font-size: 19px;
}
.rail-button small {
  font-size: 10px;
  margin-top: 3px;
}
.rail-button:hover,
.rail-button:focus-visible,
.rail-button.is-active {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-left-color: #d8877f;
  outline: none;
}
.avatar-button {
  width: 34px;
  height: 34px;
  border: 1px solid #65716d;
  background: #3d4b47;
  color: #fff;
  border-radius: 50%;
}
.queue-pane,
.conversation-pane,
.context-pane {
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.queue-pane {
  position: relative;
  display: flex;
  flex-direction: column;
}
.queue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 20px 13px;
}
.utility-label {
  margin: 0 0 4px;
  color: var(--red);
  font:
    600 9px/1.2 ui-monospace,
    SFMono-Regular,
    monospace;
}
.queue-header h1 {
  margin: 0;
  font:
    600 20px/1.2 "STSong",
    "Songti SC",
    serif;
}
.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 20px;
}
.icon-button:hover {
  border-color: var(--red);
  color: var(--red);
}
.tenant-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 20px 14px;
  color: var(--muted);
  font-size: 12px;
}
.tenant-field select {
  min-width: 0;
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  outline: none;
}
.inbox-tabs {
  display: flex;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0 14px;
}
.inbox-tabs button {
  height: 42px;
  padding: 0 8px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.inbox-tabs button.is-active {
  border-color: var(--red);
  color: var(--ink);
  font-weight: 600;
}
.inbox-tabs b {
  display: inline-block;
  margin-left: 3px;
  color: var(--red);
}
.search-field {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 14px 16px 8px;
  padding: 0 10px;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
}
.search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 12px;
}
.conversation-list {
  flex: 1;
  overflow: auto;
}
.conversation-item {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid #edf0ef;
  background: #fff;
  text-align: left;
}
.conversation-item:hover {
  background: #f8f9f8;
}
.conversation-item.is-active {
  background: #f4f7f6;
  box-shadow: inset 3px 0 var(--red);
}
.conversation-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  background: #e5ebe8;
  color: #43534e;
  font-family: "STSong", "Songti SC", serif;
}
.conversation-copy {
  min-width: 0;
}
.conversation-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.conversation-title strong {
  font-size: 13px;
}
.conversation-title time {
  color: #9aa29f;
  font-size: 10px;
}
.conversation-preview {
  overflow: hidden;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conversation-tag {
  align-self: end;
  padding: 3px 5px;
  background: var(--pine-soft);
  color: var(--pine);
  font-size: 9px;
}
.queue-status {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}
.conversation-pane {
  display: grid;
  grid-template-rows: 70px minmax(0, 1fr) auto;
}
.conversation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
}
.identity-line {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.visitor-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  background: #e6ece9;
  color: #42524d;
  font-family: "STSong", "Songti SC", serif;
}
.identity-line h2 {
  margin: 0;
  font-size: 15px;
}
.identity-line p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}
.header-actions {
  display: flex;
  gap: 7px;
}
.secondary-button,
.primary-button {
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  font-size: 12px;
}
.primary-button {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}
.primary-button:hover {
  background: var(--red-dark);
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
.message-stage {
  overflow: auto;
  padding: 22px 26px;
  background: #fafbfa;
}
.empty-conversation {
  display: grid;
  place-items: center;
  align-content: center;
  height: 100%;
  text-align: center;
  color: var(--muted);
}
.empty-seal {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 1px solid #b5c1bc;
  color: var(--red);
  font-family: "STSong", "Songti SC", serif;
  font-size: 18px;
}
.empty-conversation h2 {
  margin: 16px 0 7px;
  color: var(--ink);
  font:
    600 18px "STSong",
    "Songti SC",
    serif;
}
.empty-conversation p {
  margin: 0;
  font-size: 12px;
}
.message-row {
  display: flex;
  margin: 0 0 16px;
}
.message-row.is-agent {
  justify-content: flex-end;
}
.message-bubble {
  max-width: min(78%, 620px);
  padding: 10px 13px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
}
.is-agent .message-bubble {
  border-color: #d8e4df;
  background: var(--pine-soft);
}
.is-internal .message-bubble {
  border-style: dashed;
  background: #fff9ed;
  color: #715020;
}
.message-meta {
  margin-top: 4px;
  color: #929a97;
  font-size: 9px;
}
.composer {
  position: relative;
  padding: 0 20px 16px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.composer-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
}
.composer-tools button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}
.composer-tools button:hover {
  color: var(--red);
}
.composer-tools > span:last-child {
  margin-left: auto;
  color: var(--muted);
  font-size: 10px;
}
.ai-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--pine);
}
.composer textarea {
  display: block;
  width: 100%;
  min-height: 72px;
  resize: none;
  border: 0;
  outline: 0;
  color: var(--ink);
  line-height: 1.6;
}
.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.composer-footer span {
  color: #969e9b;
  font-size: 10px;
}
.ai-suggestion {
  position: absolute;
  right: 20px;
  bottom: 100%;
  left: 20px;
  padding: 13px 15px;
  border: 1px solid #b9cec6;
  background: #f4f8f6;
  box-shadow: var(--shadow);
}
.ai-suggestion > div {
  display: flex;
  justify-content: space-between;
}
.ai-status {
  color: var(--pine);
  font-weight: 700;
  font-size: 11px;
}
.ai-suggestion p {
  margin: 8px 0;
  color: #34413d;
  font-size: 12px;
  line-height: 1.6;
}
.ai-suggestion button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--red);
  font-size: 11px;
}
.context-pane {
  overflow: auto;
  border-right: 0;
}
.context-section {
  padding: 20px;
  border-bottom: 1px solid var(--line);
}
.section-label {
  margin: 0;
  color: #7c8683;
  font-size: 10px;
  font-weight: 700;
}
.visitor-summary dl {
  margin: 15px 0 0;
}
.visitor-summary dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  font-size: 11px;
}
.visitor-summary dt {
  color: var(--muted);
}
.visitor-summary dd {
  margin: 0;
  text-align: right;
}
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-title button {
  border: 0;
  background: transparent;
  color: var(--red);
  font-size: 11px;
}
.live-indicator {
  color: var(--pine);
  font-size: 9px;
}
.live-indicator:before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--pine);
}
.risk-note,
.empty-context {
  margin-top: 12px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}
.knowledge-source {
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}
.knowledge-source strong {
  display: block;
  margin-bottom: 3px;
}
.knowledge-source span {
  color: var(--muted);
}
dialog {
  width: min(460px, calc(100% - 28px));
  padding: 0;
  border: 0;
  box-shadow: var(--shadow);
}
dialog::backdrop {
  background: rgba(22, 30, 28, 0.45);
}
.dialog-panel {
  padding: 22px;
}
.dialog-panel header,
.dialog-panel footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.dialog-panel header h2 {
  margin: 0;
  font:
    600 19px "STSong",
    "Songti SC",
    serif;
}
.dialog-panel header button {
  border: 0;
  background: transparent;
  font-size: 24px;
}
.dialog-panel label {
  display: grid;
  gap: 7px;
  margin-top: 18px;
  font-size: 12px;
}
.dialog-panel input {
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
}
.form-help {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}
.dialog-panel footer {
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: 340px;
  padding: 11px 14px;
  background: #26322f;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 12px;
}
@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 64px 290px minmax(400px, 1fr);
  }
  .context-pane {
    display: none;
  }
}
@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 56px minmax(0, 1fr);
  }
  .queue-pane {
    grid-column: 2;
  }
  .conversation-pane {
    position: fixed;
    inset: 0 0 0 56px;
    z-index: 5;
    transform: translateX(105%);
    transition: transform 0.2s ease;
  }
  .conversation-pane.is-mobile-open {
    transform: none;
  }
  .conversation-header {
    padding: 0 12px;
  }
  .message-stage {
    padding: 18px 13px;
  }
  .composer {
    padding-right: 12px;
    padding-left: 12px;
  }
  .header-actions {
    gap: 4px;
  }
  .secondary-button {
    padding: 0 8px;
  }
  .context-pane {
    display: none;
  }
  .queue-header {
    padding-top: 15px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
