:root {
  color-scheme: light;
  --primary: #165dff;
  --primary-hover: #4080ff;
  --primary-active: #0e42d2;
  --primary-light: #e8f3ff;
  --page: #f5f7fd;
  --surface: #fff;
  --surface-soft: #f7f8fa;
  --surface-hover: #f2f3f5;
  --text-1: #121314;
  --text-2: #5c5c5c;
  --text-3: #909399;
  --border: #e5e6eb;
  --border-strong: #dcdfe6;
  --danger: #f53f3f;
  --danger-bg: #ffece8;
  --success: #00b42a;
  --success-bg: #e8ffea;
  --radius: 4px;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-drawer: -4px 0 16px rgba(0, 0, 0, 0.12);
  --font-ui: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SFMono-Regular", "Cascadia Code", "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--page); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text-1);
  background: var(--page);
  font: 14px/1.5715 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select { font: inherit; }
button { color: inherit; }
button, a, select, input[type="date"] { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid rgba(22, 93, 255, 0.3);
  outline-offset: 2px;
}
code, .mono, .mono-cell { font-family: var(--font-mono); }
h1, h2, h3, p { margin-top: 0; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}
.eyebrow { display: none; }

.brand-lockup { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-lockup strong { display: block; font-size: 18px; font-weight: 600; line-height: 1.2; color: var(--text-1); }
.brand-lockup small { display: block; margin-top: 2px; color: var(--text-3); font-size: 12px; line-height: 1.3; }
.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  border-radius: 6px;
  color: #fff;
  background: var(--primary);
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
}

/* 登录页：沿用参考项目 720 × 380 的蓝白登录卡片。 */
.login-shell {
  width: min(720px, calc(100vw - 40px));
  min-height: 380px;
  margin: max(24px, calc(50vh - 190px)) auto;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(270px, 2fr);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 8px 30px rgba(22, 93, 255, 0.06);
}
.login-story {
  position: relative;
  min-height: 380px;
  padding: 30px 32px;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(60deg, #165dff 0%, #4080ff 58%, #6aa1ff 100%);
}
.login-story::before,
.login-story::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  pointer-events: none;
}
.login-story::before { width: 260px; height: 260px; right: -82px; bottom: -102px; box-shadow: 0 0 0 34px rgba(255, 255, 255, 0.035); }
.login-story::after { width: 116px; height: 116px; right: 50px; top: 66px; background: rgba(255, 255, 255, 0.04); }
.login-story .brand-lockup { position: relative; z-index: 1; }
.login-story .brand-lockup strong { color: #fff; }
.login-story .brand-lockup small { color: rgba(255, 255, 255, 0.68); }
.login-story .brand-mark { color: var(--primary); background: rgba(255, 255, 255, 0.95); }
.login-copy { position: relative; z-index: 1; max-width: 350px; margin-top: 58px; }
.login-copy h1 { margin: 0 0 14px; color: #fff; font-size: 28px; font-weight: 500; line-height: 1.45; letter-spacing: 0.02em; }
.login-copy > p:last-child { margin: 0; color: rgba(255, 255, 255, 0.78); font-size: 13px; line-height: 1.8; }
.login-preview, .login-footnote { display: none; }
.login-panel {
  min-height: 380px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 30px;
  background: var(--surface);
}
.login-form { width: 100%; max-width: 310px; }
.login-mobile-brand { display: none; }
.login-form h2 { margin: 0 0 8px; color: var(--text-1); font-size: 20px; font-weight: 500; line-height: 32px; text-align: center; }
.login-description { margin: 0 0 24px; color: var(--text-3); font-size: 12px; line-height: 1.65; text-align: center; }
.login-description code { padding: 1px 4px; border-radius: 2px; color: var(--primary); background: var(--primary-light); font-size: 11px; }
.field-label { display: block; margin-bottom: 8px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.token-field {
  position: relative;
  height: 40px;
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.token-field:hover { border-color: var(--border-strong); }
.token-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(22, 93, 255, 0.1); }
.token-field > .icon { margin-left: 12px; color: var(--text-3); }
.token-field input {
  min-width: 0;
  flex: 1;
  height: 100%;
  padding: 0 9px;
  border: 0;
  outline: 0;
  color: var(--text-1);
  background: transparent;
  font-family: var(--font-mono);
  font-size: 13px;
}
.token-field input::placeholder { color: #c2c2c2; font-family: var(--font-ui); }
.icon-button { width: 34px; height: 34px; padding: 0; display: grid; place-items: center; border: 0; border-radius: var(--radius); color: var(--text-3); background: transparent; cursor: pointer; }
.icon-button:hover { color: var(--text-1); background: var(--surface-hover); }
.token-toggle { margin-right: 3px; }
.field-help { margin: 7px 0 0; color: var(--text-3); font-size: 12px; line-height: 1.5; }
.form-error { margin: 12px 0 0; padding: 7px 10px; border: 1px solid #fbaca3; border-radius: var(--radius); color: #cb2634; background: var(--danger-bg); font-size: 12px; }
.login-security { display: flex; align-items: center; justify-content: center; gap: 5px; margin: 14px 0 0; color: var(--text-3); font-size: 11px; }
.login-security .icon { width: 13px; height: 13px; color: var(--success); }

.primary-button, .secondary-button, .ghost-button, .small-button, .text-button, .round-button, .pager-button {
  border: 0;
  cursor: pointer;
  transition: background-color 0.18s, border-color 0.18s, color 0.18s, box-shadow 0.18s;
}
.primary-button {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 15px;
  border-radius: var(--radius);
  color: #fff;
  background: var(--primary);
  font-size: 13px;
  font-weight: 500;
}
.primary-button:hover:not(:disabled) { background: var(--primary-hover); }
.primary-button:active:not(:disabled) { background: var(--primary-active); }
.primary-button:disabled, .secondary-button:disabled, .ghost-button:disabled { opacity: 0.55; cursor: wait; }
.primary-button--full { width: 100%; min-height: 40px; margin-top: 18px; border-radius: var(--radius); font-size: 14px; }
.primary-button--full .icon { display: none; }
.secondary-button {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-1);
  background: var(--surface);
  font-size: 13px;
}
.secondary-button:hover:not(:disabled) { color: var(--primary); border-color: var(--primary); background: var(--primary-light); }
.small-button { min-height: 32px; padding: 0 14px; border-radius: var(--radius); color: #fff; background: var(--primary); font-size: 13px; }
.small-button:hover:not(:disabled) { background: var(--primary-hover); }
.text-button { min-height: 30px; padding: 0 6px; border-radius: var(--radius); color: var(--primary); background: transparent; font-size: 13px; }
.text-button:hover { background: var(--primary-light); }
.ghost-button { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-2); background: var(--surface); font-size: 13px; }
.ghost-button:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-light); }
.ghost-button .icon { width: 14px; height: 14px; }
.round-button { width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-2); background: var(--surface); }
.round-button:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-light); }
.round-button.is-loading .icon { animation: spin 0.8s linear infinite; }

/* 管理台骨架：220px 白色侧栏 + 56px 白色顶栏。 */
.admin-shell { min-height: 100vh; display: flex; background: var(--page); }
.sidebar {
  position: sticky;
  top: 0;
  width: 220px;
  height: 100vh;
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  align-self: flex-start;
  padding: 0 12px 16px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--surface);
}
.sidebar > .brand-lockup { height: 56px; flex: 0 0 56px; padding: 0 4px; }
.sidebar .brand-lockup--light strong { color: var(--text-1); }
.sidebar .brand-lockup--light small { color: var(--text-3); }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group-label { margin: 17px 8px 5px; color: var(--text-3); font-size: 12px; line-height: 20px; }
.nav-item {
  position: relative;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 14px;
  text-decoration: none;
}
.nav-item:hover { color: var(--text-1); background: var(--surface-hover); }
.nav-item--active, .nav-item--active:hover { color: var(--primary); background: var(--primary-light); }
.nav-item--active::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
.nav-item i { display: none; }
.nav-item .icon, .nav-static .icon { width: 16px; height: 16px; }
.nav-static { display: flex; align-items: flex-start; gap: 10px; padding: 8px 12px; color: var(--text-3); font-size: 12px; line-height: 1.6; }
.nav-static .icon { margin-top: 2px; }
.sidebar-note { margin-top: auto; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-soft); color: var(--text-3); }
.sidebar-note > .icon { width: 16px; height: 16px; color: var(--primary); }
.sidebar-note p { margin: 7px 0 0; display: grid; gap: 2px; font-size: 11px; line-height: 1.55; }
.sidebar-note strong { color: var(--text-2); font-size: 12px; font-weight: 500; }
.sidebar-version { margin: 14px 4px 0; color: #c2c2c2; font-size: 10px; letter-spacing: 0.08em; text-align: center; }
.workspace { min-width: 0; flex: 1; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.breadcrumb { min-width: 0; display: flex; align-items: center; gap: 7px; color: var(--text-3); font-size: 13px; white-space: nowrap; }
.breadcrumb .icon { width: 12px; height: 12px; color: #c2c2c2; }
.breadcrumb strong { overflow: hidden; color: var(--text-1); font-weight: 500; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.session-badge { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px; border-radius: 13px; color: #009a29; background: var(--success-bg); font-size: 12px; white-space: nowrap; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 2px rgba(0, 180, 42, 0.12); }

.main-content { max-width: 1600px; margin: 0 auto; padding: 16px; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.page-heading h1 { margin: 0 0 4px; color: var(--text-1); font-size: 20px; font-weight: 500; line-height: 28px; }
.page-heading p:last-child { margin: 0; color: var(--text-3); font-size: 13px; line-height: 1.6; }
.filter-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 12px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.filter-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-group--scope { justify-content: center; }
.filter-label { margin-right: 2px; color: var(--text-2); font-size: 13px; }
.date-field { position: relative; width: 140px; height: 32px; display: flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.date-field:hover { border-color: var(--border-strong); }
.date-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(22, 93, 255, 0.1); }
.date-field input { position: relative; z-index: 1; width: 100%; height: 100%; padding: 0 9px; border: 0; outline: 0; color: transparent; background: transparent; font-size: 13px; cursor: pointer; }
.date-field input:focus, .date-field.has-value input { color: var(--text-1); }
.date-field input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.date-caption { position: absolute; left: 9px; color: #c2c2c2; font-size: 13px; pointer-events: none; }
.date-field.has-value .date-caption { display: none; }
.date-separator { color: var(--text-3); font-size: 12px; }
.select-field { position: relative; width: 150px; height: 32px; display: flex; align-items: center; }
.select-field select { width: 100%; height: 100%; padding: 0 29px 0 10px; appearance: none; border: 1px solid var(--border); border-radius: var(--radius); outline: 0; color: var(--text-1); background: var(--surface); font-size: 13px; cursor: pointer; }
.select-field--scope { width: 170px; }
.select-field select:hover { border-color: var(--border-strong); }
.select-field:focus-within select { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(22, 93, 255, 0.1); }
.select-field select:disabled { color: var(--text-3); background: var(--surface-hover); cursor: not-allowed; }
.select-field .icon { position: absolute; right: 9px; width: 12px; height: 12px; color: var(--text-3); pointer-events: none; }
.filter-panel .primary-button, .filter-panel .secondary-button { min-height: 32px; padding: 0 15px; font-size: 13px; }
.filter-panel .primary-button .icon, .filter-panel .secondary-button .icon { width: 14px; height: 14px; }
.error-banner { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding: 9px 12px; border: 1px solid #fbaca3; border-radius: var(--radius); color: #cb2634; background: var(--danger-bg); font-size: 13px; }
.error-banner .icon { width: 15px; height: 15px; }
.error-banner button { margin-left: auto; border: 0; color: var(--primary); background: transparent; cursor: pointer; }

/* 会话表格 */
.table-card { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-card); }
.table-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; }
.table-heading h2 { margin: 0 0 3px; font-size: 16px; font-weight: 500; line-height: 24px; }
.table-heading p { margin: 0; color: var(--text-3); font-size: 12px; }
.result-count { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.table-scroll { overflow-x: auto; border-top: 1px solid var(--border); }
.data-table { width: 100%; min-width: 1120px; border-collapse: collapse; table-layout: fixed; }
.data-table th { height: 44px; padding: 0 12px; color: var(--text-2); background: var(--surface-soft); border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; text-align: left; white-space: nowrap; }
.data-table td { height: 56px; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-2); font-size: 13px; }
.data-table th:first-child, .data-table td:first-child { padding-left: 20px; }
.data-table th:last-child, .data-table td:last-child { padding-right: 20px; }
.data-table tbody > tr.conversation-row { transition: background-color 0.16s; }
.data-table tbody > tr.conversation-row:hover { background: #fafbfc; }
.data-table tbody > tr.conversation-row.is-expanded { background: #f7fbff; }
.data-table tbody > tr:last-child td { border-bottom: 0; }
.col-external { width: 160px; }
.col-time { width: 148px; }
.col-center { width: 74px; text-align: center !important; }
.col-action { width: 142px; text-align: right !important; }
.cell-primary { display: block; color: var(--text-1); font-weight: 400; line-height: 1.5; overflow-wrap: anywhere; }
.cell-sub { display: block; margin-top: 2px; color: var(--text-3); font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
.cell-muted { color: var(--text-3); }
.mono-cell { font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.avatar-badge { width: 32px; height: 32px; display: grid; place-items: center; overflow: hidden; border-radius: 50%; color: #fff; background: var(--primary); font-size: 13px; font-weight: 500; }
.avatar-badge img { width: 100%; height: 100%; object-fit: cover; }
.tag { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 22px; padding: 0 7px; border-radius: 2px; color: var(--primary); background: var(--primary-light); font-size: 12px; line-height: 22px; }
.tag--muted { color: var(--text-3); background: var(--surface-hover); }
.row-action { min-height: 28px; display: inline-flex; align-items: center; gap: 5px; padding: 0 11px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-1); background: var(--surface); font-size: 12px; cursor: pointer; white-space: nowrap; }
.row-action:hover:not(:disabled) { color: var(--primary); border-color: var(--primary); background: var(--primary-light); }
.row-action:disabled { color: #c2c2c2; border-color: var(--border); background: var(--surface-soft); cursor: not-allowed; }
.row-action .icon { width: 13px; height: 13px; transition: transform 0.2s; }
.row-action > svg { width: 13px; height: 13px; flex: 0 0 13px; fill: none; stroke: currentColor; }
.row-action[aria-expanded="true"] .icon { transform: rotate(180deg); }
.detail-cell { padding: 0 !important; background: var(--surface-soft); }
.conversation-details { width: 100%; border-collapse: collapse; table-layout: fixed; }
.conversation-details th { height: 36px; padding: 0 20px; color: var(--text-3); background: #f2f3f5; border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 500; }
.conversation-details td { height: 48px; padding: 7px 20px; border-bottom: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 12px; }
.conversation-details tr:last-child td { border-bottom: 0; }
.detail-link { padding: 0; border: 0; color: var(--primary); background: transparent; cursor: pointer; font-size: 12px; }
.detail-link:hover:not(:disabled) { color: var(--primary-hover); text-decoration: underline; }
.detail-link:disabled { color: #c2c2c2; cursor: not-allowed; }
.empty-state { min-height: 240px; display: grid; place-items: center; padding: 32px; text-align: center; }
.empty-state > div { max-width: 360px; }
.empty-icon { width: 48px; height: 48px; display: grid; place-items: center; margin: 0 auto 12px; border-radius: 50%; color: var(--text-3); background: var(--surface-hover); }
.empty-icon .icon { width: 22px; height: 22px; }
.empty-state strong { display: block; color: var(--text-2); font-size: 14px; font-weight: 500; line-height: 22px; }
.empty-state p { margin: 4px 0 0; color: var(--text-3); font-size: 12px; }
.skeleton-row td { height: 56px; }
.skeleton-line { height: 10px; border-radius: 2px; background: linear-gradient(90deg, #f2f3f5 20%, #fafafa 42%, #f2f3f5 63%); background-size: 300% 100%; animation: shimmer 1.4s infinite; }
.skeleton-dot { width: 32px; height: 32px; border-radius: 50%; background: #f2f3f5; }
.table-footer { min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface); }
.page-size { display: flex; align-items: center; gap: 7px; color: var(--text-3); font-size: 12px; white-space: nowrap; }
.page-size select { height: 30px; padding: 0 24px 0 9px; appearance: none; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-1); background: var(--surface); font-size: 12px; cursor: pointer; }
.page-size #pageSummary { margin-left: 4px; color: var(--text-3); }
.pager { display: flex; align-items: center; gap: 6px; }
.pager-button { min-width: 30px; height: 30px; display: inline-grid; place-items: center; padding: 0 7px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-2); background: var(--surface); font-size: 12px; }
.pager-button:hover:not(:disabled) { color: var(--primary); border-color: var(--primary); background: var(--primary-light); }
.pager-button[aria-current="page"] { color: #fff; border-color: var(--primary); background: var(--primary); }
.pager-button:disabled { color: #c2c2c2; border-color: var(--border); background: var(--surface-soft); cursor: not-allowed; }
.pager-button .icon { width: 13px; height: 13px; }
.pager-gap { padding: 0 2px; color: var(--text-3); font-size: 12px; }

/* 聊天记录抽屉，宽度与参考项目保持一致。 */
.drawer-root { position: fixed; inset: 0; z-index: 50; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(29, 33, 41, 0.6); animation: fade-in 0.2s both; }
.chat-drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(720px, 100vw); display: flex; flex-direction: column; background: var(--surface); box-shadow: var(--shadow-drawer); animation: drawer-in 0.24s cubic-bezier(0.22, 0.8, 0.24, 1) both; }
.drawer-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.drawer-header h2 { margin: 0; font-size: 16px; font-weight: 500; line-height: 24px; }
.chat-context { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--surface); }
.context-avatar { width: 36px; height: 36px; display: grid; place-items: center; overflow: hidden; border-radius: 50%; color: #fff; background: var(--primary); font-size: 14px; font-weight: 500; }
.context-avatar img { width: 100%; height: 100%; object-fit: cover; }
.context-main { min-width: 0; }
.context-main strong { display: block; overflow: hidden; color: var(--text-1); font-size: 14px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.context-main p { margin: 2px 0 0; overflow: hidden; color: var(--text-3); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.context-tags { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.context-tags span { min-height: 24px; display: inline-flex; align-items: center; gap: 4px; padding: 0 7px; border-radius: 2px; color: var(--text-2); background: var(--surface-soft); font-size: 11px; }
.context-tags .icon { width: 12px; height: 12px; color: var(--text-3); }
.context-tags b { max-width: 150px; overflow: hidden; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.chat-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--surface); }
.compact-date { height: 32px; display: inline-flex; align-items: center; gap: 5px; padding: 0 9px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-3); font-size: 12px; }
.compact-date:focus-within { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(22, 93, 255, 0.1); }
.compact-date .icon { width: 14px; height: 14px; }
.compact-date input { width: 116px; padding: 0; border: 0; outline: 0; color: var(--text-1); background: transparent; font-size: 12px; }
.message-status { min-height: 26px; padding: 5px 20px 0; color: var(--text-3); background: var(--surface); font-size: 11px; }
.message-viewport { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 20px 24px; background: #fbfcff; }
.message-top { min-height: 36px; display: flex; align-items: center; justify-content: center; color: var(--text-3); font-size: 12px; text-align: center; }
.load-earlier { margin: 4px auto 12px; padding: 5px 12px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--primary); background: var(--surface); font-size: 12px; cursor: pointer; }
.load-earlier:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-light); }
.load-earlier:disabled { color: var(--text-3); cursor: wait; }
.message-top-error { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; color: var(--danger); font-size: 12px; }
.message-top-error button { border: 0; color: var(--primary); background: transparent; cursor: pointer; font-size: 12px; }
.message-list { min-height: 120px; }
.day-divider { display: flex; align-items: center; gap: 10px; margin: 12px 0 18px; color: var(--text-3); font-size: 11px; line-height: 18px; text-align: center; }
.day-divider::before, .day-divider::after { content: ""; height: 1px; flex: 1; background: var(--border); }
.chat-message { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 18px; animation: message-in 0.2s both; }
.chat-message.is-outgoing { flex-direction: row-reverse; }
.message-avatar { width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; overflow: hidden; border-radius: 50%; color: #fff; background: #86909c; font-size: 12px; }
.message-avatar img { width: 100%; height: 100%; object-fit: cover; }
.message-body { max-width: 80%; min-width: 0; }
.message-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 5px; color: var(--text-3); font-size: 11px; line-height: 18px; }
.message-meta strong { color: var(--text-2); font-size: 12px; font-weight: 400; }
.message-meta time { color: var(--text-3); }
.is-outgoing .message-meta { justify-content: flex-end; }
.is-outgoing .message-body { text-align: right; }
.hidden-mark { padding: 0 4px; border-radius: 2px; color: var(--text-3); background: var(--surface-hover); font-size: 10px; }
.message-bubble { display: inline-block; max-width: 100%; padding: 9px 12px; border-radius: 4px; color: var(--text-1); background: var(--surface-hover); font-size: 14px; line-height: 22px; text-align: left; overflow-wrap: anywhere; }
.is-outgoing .message-bubble { background: rgba(22, 93, 255, 0.08); }
.message-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-text + .message-text, .message-text + .message-placeholder, .message-placeholder + .message-text { margin-top: 6px; }
.message-placeholder { margin: 0; color: var(--text-3); font-size: 12px; }
.message-media { display: block; max-width: min(320px, 100%); max-height: 280px; border-radius: 3px; }
.media-link { display: inline-block; max-width: 100%; }
.system-message { margin: 12px auto; padding: 5px 10px; color: var(--text-3); font-size: 11px; text-align: center; }
.message-empty { min-height: 240px; display: grid; place-items: center; text-align: center; }
.message-empty .empty-icon { background: var(--surface-hover); color: var(--text-3); }
.message-loading { display: grid; gap: 12px; padding: 16px 12%; }
.message-loading .bubble-skeleton { height: 46px; border-radius: var(--radius); background: linear-gradient(90deg, #f2f3f5 20%, #fafafa 42%, #f2f3f5 63%); background-size: 300% 100%; animation: shimmer 1.4s infinite; }
.message-loading .bubble-skeleton:nth-child(even) { width: 70%; margin-left: auto; }
.message-error { max-width: 360px; margin: 24px auto; padding: 12px; border: 1px solid #fbaca3; border-radius: var(--radius); color: #cb2634; background: var(--danger-bg); font-size: 12px; text-align: center; }
.message-error button { margin-top: 8px; border: 0; color: var(--primary); background: transparent; cursor: pointer; }

/* 反馈与动画 */
.toast-region { position: fixed; z-index: 80; right: 20px; bottom: 20px; display: grid; gap: 8px; pointer-events: none; }
.toast { min-width: 210px; max-width: 380px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-1); background: var(--surface); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1); font-size: 13px; animation: toast-in 0.2s both; }
.toast--error { color: #cb2634; border-color: #fbaca3; background: var(--danger-bg); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes drawer-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes message-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

@media (max-width: 1120px) {
  .filter-panel { align-items: flex-start; flex-direction: column; }
  .filter-group { width: 100%; }
  .filter-group--scope { justify-content: flex-start; }
}
@media (max-width: 900px) {
  .admin-shell { display: block; }
  .sidebar { position: relative; width: 100%; height: auto; flex-direction: row; align-items: center; gap: 16px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar > .brand-lockup { height: 40px; flex: 0 0 auto; padding: 0; }
  .side-nav { flex: 1; flex-direction: row; justify-content: flex-end; margin-left: auto; }
  .nav-group-label, .nav-static, .sidebar-note, .sidebar-version { display: none; }
  .nav-item { height: 36px; padding: 0 10px; }
  .nav-item--active::before { top: 8px; bottom: 8px; }
  .topbar { top: 0; }
  .main-content { padding-top: 14px; }
}
@media (max-width: 760px) {
  .login-shell { width: min(420px, calc(100vw - 32px)); min-height: 420px; margin: 24px auto; display: block; }
  .login-story { display: none; }
  .login-panel { min-height: 420px; padding: 32px 26px; }
  .login-mobile-brand { display: flex; margin-bottom: 26px; }
  .login-mobile-brand .brand-mark { width: 34px; height: 34px; flex-basis: 34px; }
}
@media (max-width: 680px) {
  .topbar { padding: 0 12px; }
  .breadcrumb span, .session-badge { display: none; }
  .main-content { padding: 12px; }
  .page-heading h1 { font-size: 18px; }
  .page-heading p:last-child { max-width: 280px; font-size: 12px; }
  .filter-panel { padding: 12px; }
  .filter-group { width: 100%; }
  .date-field { width: calc(50% - 18px); }
  .select-field--scope { flex: 1; min-width: 125px; }
  .select-field { width: calc(100% - 168px); min-width: 125px; }
  .table-heading { align-items: flex-start; padding: 14px 16px; }
  .table-footer { align-items: flex-start; flex-direction: column; padding: 12px 16px; }
  .pager { width: 100%; justify-content: flex-end; }
  .chat-drawer { width: 100%; }
  .drawer-header, .chat-context, .chat-toolbar, .message-status, .message-viewport { padding-left: 16px; padding-right: 16px; }
  .chat-context { grid-template-columns: auto minmax(0, 1fr); }
  .context-tags { grid-column: 1 / -1; justify-content: flex-start; padding-left: 46px; }
  .chat-toolbar { gap: 7px; }
  .compact-date { flex: 1; min-width: 142px; }
  .compact-date input { width: 100%; }
  .message-body { max-width: 82%; }
  .toast-region { right: 12px; bottom: 12px; left: 12px; }
  .toast { max-width: none; }
}
@media (max-width: 430px) {
  .login-shell { width: calc(100vw - 24px); margin: 12px auto; }
  .login-panel { padding: 28px 20px; }
  .filter-group:last-child { gap: 7px; }
  .select-field { width: 100%; }
  .filter-panel .primary-button, .filter-panel .secondary-button { flex: 1; }
  .message-avatar { display: none; }
  .message-body { max-width: 92%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
