:root {
  color-scheme: light;
  --theme: #1a73e8;
  --theme-strong: var(--theme);
  --theme-soft: rgba(26, 115, 232, .1);
  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-2: #fbfcfe;
  --panel-3: #f7f9fc;
  --panel-4: #eef1f6;
  --panel-tint: #eef3ff;
  --text: #1f2733;
  --muted: #667085;
  --line: #e7ebf2;
  --line-strong: #dbe2ec;
  --danger: #d92d20;
  --green: #0b6b3a;
  --amber: #a16207;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(31, 39, 51, .08);
  --shadow-color: rgba(18, 24, 34, .18);
  --overlay: rgba(18, 24, 34, .42);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1100px 560px at 50% -12%, var(--theme-soft), transparent 62%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1200px;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  box-shadow: var(--shadow);
}

/* ---------- 顶栏 ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.97);
  flex: none;
  position: relative;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; min-width: 0; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--theme);
  box-shadow: 0 0 0 4px var(--theme-soft);
  flex: none;
}
.user-area { display: flex; align-items: center; gap: 8px; flex: none; flex-wrap: wrap; justify-content: flex-end; }
.status-badge {
  font-size: 12px;
  color: var(--muted);
  background: #f1f4f9;
  border-radius: 999px;
  padding: 5px 10px;
  white-space: nowrap;
}
.status-badge.online { color: var(--green); background: #e6f7ee; }
.status-badge.offline { color: var(--amber); background: #fdf3d7; }

.primary-btn {
  border: none; background: var(--theme); color: #fff; font-size: 14px; font-weight: 600;
  padding: 11px 20px; border-radius: 11px; cursor: pointer;
}
.primary-btn:hover { filter: brightness(1.05); }
.primary-btn:disabled { opacity: .55; cursor: not-allowed; }
.primary-btn.sm { padding: 8px 13px; font-size: 13px; border-radius: 9px; }
.ghost-btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 9px 14px; border-radius: 9px; cursor: pointer; font-size: 13px;
}
.ghost-btn:hover { border-color: var(--theme); color: var(--theme); }
.ghost-btn.sm { padding: 6px 12px; font-size: 12.5px; }

.action-btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  font-size: 13px; padding: 8px 11px; border-radius: 9px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
}
.action-btn:hover { border-color: var(--theme); color: var(--theme); }
.action-btn:disabled { opacity: .45; cursor: not-allowed; }
.action-btn:disabled:hover { border-color: var(--line); color: var(--text); }
.theme-btn { white-space: nowrap; }

.count-badge {
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 999px;
  background: var(--theme); color: #fff; font-size: 11px; line-height: 17px; text-align: center;
}
.count-badge.alert {
  background: var(--danger);
  animation: badgePulse 1.15s ease-in-out infinite;
}
@keyframes badgePulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(229, 72, 77, .45); }
  50% { transform: scale(1.14); box-shadow: 0 0 0 5px rgba(229, 72, 77, 0); }
}

.alert-banner {
  display: flex; align-items: center; gap: 10px; flex: none;
  padding: 10px 14px; border-bottom: 1px solid #f5d0a9; border-left: 4px solid #f59e0b;
  background: linear-gradient(90deg, #fff4e5, #fffaf2);
  animation: alertSlide .25s ease-out;
}
.alert-banner-icon {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: #f59e0b; color: #fff; font-size: 15px; font-weight: 800;
}
.alert-banner-main { flex: 1; min-width: 0; }
.alert-banner-title { font-size: 14px; font-weight: 700; color: #92400e; }
.alert-banner-text {
  margin-top: 2px; font-size: 12.5px; color: #a16207;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.alert-banner .primary-btn.sm { flex: none; min-height: 36px; background: #f59e0b; }
.alert-banner .icon-close {
  flex: none; width: 36px; height: 36px; margin: -6px -6px -6px 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 8px;
  border: none; background: none; color: #a16207; font-size: 20px; cursor: pointer;
}
.alert-banner .icon-close:hover { background: rgba(161, 98, 7, .1); }
@keyframes alertSlide {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.user-chip { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
.link-btn {
  border: none; background: none; cursor: pointer; font-size: 13px; padding: 5px 7px; border-radius: 7px;
  color: var(--muted);
}
.link-btn:hover { color: var(--danger); }

/* 手机端更多菜单 */
.more-wrap { position: relative; display: none; }
.more-btn { min-width: 40px; min-height: 36px; justify-content: center; font-size: 18px; line-height: 1; padding: 7px 10px; }
.more-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 70;
  width: 224px; padding: 6px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 18px 44px rgba(18, 24, 34, .18);
}
.more-user {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px 9px; margin-bottom: 4px; border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.more-user-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.more-user-tag { flex: none; font-size: 10.5px; color: var(--muted); }
.more-item {
  width: 100%; display: flex; align-items: center; gap: 8px;
  min-height: 44px;
  border: none; background: none; color: var(--text);
  padding: 10px; border-radius: 8px; font: inherit; font-size: 13px;
  text-align: left; cursor: pointer;
}
.more-item:hover { background: var(--panel-3); color: var(--theme); }
.more-item.danger { color: var(--danger); }
.more-item.danger:hover { background: rgba(217, 45, 32, .08); color: var(--danger); }

/* ---------- 聊天区 ---------- */

.chat-main { flex: 1; min-height: 0; display: flex; flex-direction: row; }
.chat-column { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- 桌面端右侧信息栏 ---------- */

.desktop-side {
  flex: none; width: 300px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
  padding: 24px 22px calc(24px + env(safe-area-inset-bottom));
  border-left: 1px solid var(--line);
  background: var(--panel-2);
}
.side-hero { padding: 2px 4px 6px; }
.side-eyebrow { font-size: 10.5px; font-weight: 800; letter-spacing: .14em; color: var(--theme); }
.side-title { margin-top: 6px; font-size: 21px; font-weight: 800; letter-spacing: -.01em; line-height: 1.25; }
.side-desc { margin: 8px 0 0; font-size: 12.5px; line-height: 1.7; color: var(--muted); }
.side-card { border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 14px; }
.side-card-title { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; color: var(--muted); }
.side-service { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.side-service-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 700; }
.side-service-status {
  flex: none; font-size: 11px; font-weight: 600; border-radius: 999px;
  padding: 2px 8px; background: var(--theme-soft); color: var(--theme); white-space: nowrap;
}
.side-service-status.tone-active { background: #e6f7ee; color: #0b6b3a; }
.side-service-status.tone-waiting { background: #fdf3d7; color: var(--amber); }
.side-service-status.tone-held,
.side-service-status.tone-ticket { background: #fff1e6; color: #b45309; }
.side-service-status.tone-ended { background: #eef1f6; color: #5b6472; }
.side-meta { margin-top: 6px; font-size: 12px; line-height: 1.6; color: var(--muted); }
.side-status { display: flex; align-items: center; gap: 7px; margin-top: 8px; font-size: 12.5px; font-weight: 600; }
.side-status-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.side-status-dot.online { background: var(--green); box-shadow: 0 0 0 3px rgba(15, 138, 74, .12); }
.side-status-dot.offline { background: var(--amber); box-shadow: 0 0 0 3px rgba(161, 98, 7, .12); }
.side-action {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 8px; padding: 10px 11px; border: none; border-radius: 9px;
  background: var(--panel-3); color: var(--text); font: inherit; font-size: 12.5px;
  font-weight: 600; text-align: left; cursor: pointer;
}
.side-action::after { content: "›"; color: var(--muted); font-size: 16px; line-height: 1; }
.side-action:hover { background: var(--theme-soft); color: var(--theme); }
.side-action:hover::after { color: var(--theme); }
.side-foot { margin-top: auto; padding: 12px 4px 0; font-size: 11.5px; line-height: 1.65; color: var(--muted); }

/* ---------- 对话标签 ---------- */

.chat-tabs {
  display: flex; align-items: stretch; gap: 4px; flex: none;
  padding: 0 12px; background: #fff; border-bottom: 1px solid var(--line);
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.chat-tabs::-webkit-scrollbar { display: none; }
.chat-tabs.overflow-right { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
.chat-tabs.overflow-left { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 28px), transparent); }
.chat-tabs.overflow-left.overflow-right {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
}
.chat-tab {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  max-width: 240px; padding: 10px 9px 8px; border: none;
  border-bottom: 2px solid transparent; background: transparent;
  color: var(--muted); font-family: inherit; font-size: 12.5px; cursor: pointer;
  white-space: nowrap; scroll-snap-align: start;
}
.chat-tab:hover { color: var(--text); background: #f7f9fc; }
.chat-tab.active { color: var(--theme); border-bottom-color: var(--theme); font-weight: 600; }
.chat-tab-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--theme); flex: none; }
.chat-tab-dot.ticket { background: #f59e0b; }
.chat-tab-dot.waiting { background: #f59e0b; }
.chat-tab-dot.held { background: #8b5cf6; }
.chat-tab-dot.closed { background: #98a2b3; }
.chat-tab-label { overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.chat-tab-meta { font-size: 10.5px; color: var(--muted); flex: none; }
.chat-tab-unread {
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
  flex: none;
}

/* ---------- 当前服务身份 ---------- */

.service-identity {
  flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: #f8faff;
}
.service-avatar {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; letter-spacing: .2px;
}
.service-main { flex: 1; min-width: 0; }
.service-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.service-title { font-size: 13.5px; font-weight: 700; line-height: 1.3; }
.service-status {
  font-size: 11px; font-weight: 600; border-radius: 999px;
  padding: 2px 8px; white-space: nowrap;
}
.service-sub {
  margin-top: 2px; font-size: 11.5px; color: var(--muted); line-height: 1.4;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.service-identity.mode-ai { background: #f8faff; }
.service-identity.mode-ai .service-avatar { background: var(--theme-soft); color: var(--theme); }
.service-identity.mode-human { background: #f5fcf8; }
.service-identity.mode-human .service-avatar { background: #e6f7ee; color: #0b6b3a; }
.service-identity.mode-ticket { background: #fffbf5; }
.service-identity.mode-ticket .service-avatar { background: #fff1e6; color: #b45309; }
.service-identity.mode-ended { background: #f7f8fb; }
.service-identity.mode-ended .service-avatar { background: #eef1f6; color: #667085; }
.service-status.tone-ai { background: var(--theme-soft); color: var(--theme); }
.service-status.tone-active { background: #e6f7ee; color: #0b6b3a; }
.service-status.tone-waiting { background: #fdf3d7; color: #a16207; }
.service-status.tone-held { background: #fff4e5; color: #b45309; }
.service-status.tone-ticket { background: #fff1e6; color: #b45309; }
.service-status.tone-ended { background: #eef1f6; color: #667085; }

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 18px 10px;
  scroll-behavior: smooth;
}

.welcome {
  max-width: 520px;
  margin: 34px auto 0;
  text-align: center;
  padding: 0 6px;
}
.welcome-avatar {
  width: 46px; height: 46px; margin: 0 auto 12px;
  border-radius: 15px; background: var(--theme-soft); color: var(--theme);
  font-weight: 800; font-size: 15px; display: flex; align-items: center; justify-content: center;
}
.welcome-title { font-size: 19px; font-weight: 700; }
.welcome-desc { color: var(--muted); font-size: 13px; line-height: 1.7; margin: 7px auto 18px; max-width: 420px; }
.welcome-guide {
  max-width: 460px; margin: 0 auto 16px; display: flex; flex-direction: column; gap: 8px; text-align: left;
}
.welcome-guide-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: #fbfcfe;
}
.welcome-guide-icon {
  flex: none; width: 28px; height: 28px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--theme-soft); color: var(--theme);
}
.welcome-guide-icon svg { width: 16px; height: 16px; stroke-width: 2; }
.welcome-guide-text { min-width: 0; }
.welcome-guide-text strong { display: block; font-size: 12.5px; line-height: 1.5; color: var(--text); }
.welcome-guide-text p { margin: 2px 0 0; font-size: 11.5px; line-height: 1.55; color: var(--muted); }
.quick-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 20px; }
.quick-chip {
  border: 1px solid var(--line); background: #fbfcfe; color: var(--text);
  padding: 8px 12px; border-radius: 999px; font-size: 12.5px; cursor: pointer;
}
.quick-chip:hover { border-color: var(--theme); color: var(--theme); background: var(--theme-soft); }
.welcome-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.msg-row { display: flex; gap: 8px; margin-bottom: 14px; align-items: flex-end; }
.msg-row.mine { flex-direction: row-reverse; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--theme-soft); color: var(--theme); font-size: 11px; font-weight: 700;
}
.msg-col { max-width: 76%; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.msg-row.mine .msg-col { align-items: flex-end; }
.bubble {
  max-width: 100%;
  padding: 10px 13px;
  border-radius: 14px;
  background: #f2f4f8;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}
.msg-row.mine .bubble { background: var(--theme); color: #fff; border-bottom-right-radius: 4px; }
.msg-row:not(.mine) .bubble { border-bottom-left-radius: 4px; }
.chat-link {
  color: var(--theme); text-decoration: underline; text-underline-offset: 2px;
  word-break: break-all;
}
.chat-link:hover { filter: brightness(1.12); }
.msg-row.mine .bubble .chat-link { color: #fff; text-decoration-color: rgba(255, 255, 255, .75); }
.msg-row .bubble.media-bubble,
.msg-row.mine .bubble.media-bubble { padding: 4px; background: #eef1f6; color: var(--text); }
.media-wrap {
  position: relative; display: block; max-width: 100%; min-width: 120px;
  border-radius: 10px; overflow: hidden; background: #eef1f6;
}
.media-wrap img, .media-wrap video { display: block; max-width: 100%; border-radius: 10px; }
.media-wrap video { max-height: 320px; background: #000; }
.media-wrap.loading { min-height: 160px; }
.media-wrap.loading img, .media-wrap.loading video { opacity: 0; }
.media-wrap.ready img, .media-wrap.ready video { opacity: 1; transition: opacity .2s ease; }
.media-wrap.pending-media { min-height: 0; }
.media-wrap.pending-media img, .media-wrap.pending-media video { opacity: 1; }
.media-wrap.pending-media img { max-height: 280px; object-fit: cover; }
.media-wrap.failed { min-height: 120px; }
.media-skeleton {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #7a8496; font-size: 12px;
  background: linear-gradient(100deg, #eef1f6 20%, #f7f9fc 40%, #eef1f6 60%);
  background-size: 220% 100%; animation: media-shimmer 1.4s ease-in-out infinite;
}
.media-wrap.failed .media-skeleton { background: #fdf2f2; color: #b42318; }
.upload-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; padding: 12px;
  color: #fff; background: rgba(17, 24, 39, .48);
}
.upload-spinner {
  width: 26px; height: 26px; border: 3px solid rgba(255, 255, 255, .35);
  border-top-color: #fff; border-radius: 50%; animation: upload-spin .8s linear infinite;
}
.upload-label { font-size: 12px; line-height: 1.4; text-align: center; }
.upload-bar { width: 120px; max-width: 70%; height: 4px; border-radius: 2px; overflow: hidden; background: rgba(255, 255, 255, .3); }
.upload-fill { width: 0; height: 100%; background: #fff; transition: width .2s ease; }
.msg-row.failed .upload-overlay { background: rgba(180, 35, 24, .62); }
.upload-retry { color: #fff; text-decoration: underline; font-size: 12px; }
.bubble img, .bubble video { max-width: 100%; border-radius: 10px; display: block; }
.bubble video { max-height: 320px; background: #000; }
.media-actions {
  position: absolute; top: 6px; right: 6px; display: flex; gap: 5px;
  opacity: 0; transition: opacity .15s; z-index: 2;
}
.media-wrap:hover .media-actions { opacity: 1; }
.media-action-btn {
  border: none; background: rgba(17, 24, 39, .68); color: #fff;
  min-height: 28px; font-size: 11px; padding: 5px 8px; border-radius: 7px; cursor: pointer;
  text-decoration: none; line-height: 1.3;
}
.media-action-btn:hover { background: rgba(17, 24, 39, .85); }
@media (hover: none) { .media-actions { opacity: 1; } }

/* ---------- 文件消息 ---------- */

.msg-row .bubble.file-bubble,
.msg-row.mine .bubble.file-bubble { padding: 6px; background: #eef1f6; color: var(--text); white-space: normal; }
.file-card {
  display: flex; align-items: center; gap: 10px;
  width: 300px; max-width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--text); text-decoration: none;
}
a.file-card:hover { border-color: var(--theme); background: var(--theme-soft); }
.file-icon {
  flex: none; width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: var(--theme-soft); font-size: 18px;
}
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 13px; font-weight: 600; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.file-download { flex: none; font-size: 12px; color: var(--theme); font-weight: 600; }
.pending-file-card { border-style: dashed; }
.file-progress { margin-top: 6px; }
.file-progress .upload-label { color: var(--muted); text-align: left; font-size: 11.5px; }
.file-progress .upload-bar { width: 100%; height: 4px; margin-top: 4px; background: #e5eaf3; }
.file-progress .upload-fill { background: var(--theme); }
.file-progress .upload-retry { display: inline-block; margin-top: 4px; color: #b42318; }
.msg-row.failed .file-progress .upload-label { color: #b42318; }
.msg-row.failed .file-progress .upload-fill { background: #b42318; }
.media-lightbox {
  position: fixed; inset: 0; z-index: 120; display: flex; flex-direction: column;
  background: rgba(10, 14, 20, .92);
}
.media-lightbox-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px; color: #fff; font-size: 14px; flex: none;
}
.media-lightbox-actions { display: flex; gap: 8px; }
.lightbox-btn {
  border: 1px solid rgba(255, 255, 255, .3); background: rgba(255, 255, 255, .08);
  color: #fff; border-radius: 8px; padding: 7px 12px; font-size: 12.5px;
  cursor: pointer; text-decoration: none; line-height: 1.3;
}
.lightbox-btn:hover { background: rgba(255, 255, 255, .16); }
.media-lightbox-body {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  padding: 10px 20px 30px;
}
.media-lightbox-body img, .media-lightbox-body video {
  max-width: 100%; max-height: 100%; border-radius: 8px; background: #000;
}
.msg-meta { font-size: 11px; color: var(--muted); padding: 0 4px; }
.system-msg { text-align: center; margin: 12px 0; }
.system-msg span {
  display: inline-block; max-width: 88%; font-size: 12px; color: var(--muted);
  background: #f5f7fb; border-radius: 10px; padding: 6px 12px; line-height: 1.5;
}
.typing { color: var(--muted); font-size: 13px; padding: 4px 8px; }
.typing-row {
  display: flex; gap: 8px; margin-bottom: 14px; align-items: flex-end;
  animation: typing-row-in .18s ease-out;
}
.typing-row .bubble { border-bottom-left-radius: 4px; }
.typing-bubble {
  display: inline-flex; align-items: center; gap: 4px;
  min-width: 56px; padding: 13px 14px;
}
.typing-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted);
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: .16s; }
.typing-dot:nth-child(3) { animation-delay: .32s; }
.typing-row .msg-meta { color: var(--muted); }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: 1; }
}
@keyframes typing-row-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .typing-row { animation: none; }
  .typing-dot { animation: none; opacity: .6; }
}

/* ---------- 状态条 ---------- */

.state-bar {
  flex: none;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  background: #fbfcfe;
  font-size: 13px;
  line-height: 1.5;
}
.state-bar.waiting { background: var(--theme-soft); }
.state-bar.active { background: #eaf7ef; }
.state-bar.held { background: #fff7ed; }
.state-bar.hold-pending { background: #fff4e5; border-top-color: #f5d0a9; }
.state-bar.closed { background: #f7f8fb; }
.state-bar.offline { background: #fdf3d7; }
.state-bar.offline-wait { background: #fff4e5; border-top-color: #f5d0a9; }
.state-text { flex: 1; min-width: 160px; }
.state-hint { flex-basis: 100%; font-size: 12px; color: var(--amber); }
.state-bar .link-btn { flex: none; min-height: 32px; text-decoration: underline; color: var(--theme); }
.state-bar .link-btn:hover { color: var(--theme); }
.state-bar .hold-accept { color: #b45309; font-weight: 700; }
.state-bar .hold-reject { color: var(--muted); }

/* ---------- 输入区 ---------- */

.composer {
  position: relative;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #fff;
  flex: none;
}
.composer-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.composer-count { margin-left: auto; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.composer-count.limit { color: var(--danger); font-weight: 600; }
.composer-staged { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 0; }
.composer-staged[hidden] { display: none; }
.staged-image {
  position: relative; width: 64px; height: 64px; border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden; background: var(--panel-2, #f2f4f8);
}
.staged-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.staged-image button {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; padding: 0;
  border: 0; border-radius: 50%; background: rgba(17, 24, 39, .62); color: #fff;
  font-size: 14px; line-height: 20px; text-align: center; cursor: pointer;
}
.staged-image button:hover { background: rgba(17, 24, 39, .84); }
.composer-input-row { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  line-height: 1.5;
  min-height: 96px;
  max-height: 200px;
  outline: none;
  background: #fbfcfe;
}
.composer textarea:focus { border-color: var(--theme); background: #fff; }
.send-btn {
  flex: none; border: none; background: var(--theme); color: #fff;
  min-height: 40px; padding: 10px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; cursor: pointer;
  align-self: flex-end;
}
.send-btn:disabled { opacity: .5; cursor: not-allowed; }
.tool-btn {
  flex: none; border: 1px solid var(--line); background: #fff; color: var(--muted);
  min-height: 32px; padding: 9px 10px; border-radius: 10px; font-size: 12px; cursor: pointer;
}
.tool-btn:hover { color: var(--theme); border-color: var(--theme); }
.tool-btn:disabled { opacity: .45; cursor: not-allowed; }
.tool-btn:disabled:hover { color: var(--muted); border-color: var(--line); }
.composer-toolbar .tool-btn {
  border-color: transparent; background: #f5f7fb; color: #5b6472;
  padding: 5px 10px; border-radius: 8px; font-size: 12.5px; line-height: 1.4;
}
.composer-toolbar .tool-btn:hover:not(:disabled) {
  background: #eef3ff; color: var(--theme); border-color: #dbe8ff;
}
.emoji-btn { font-size: 18px; line-height: 1; padding: 7px 9px; }
.composer-toolbar .emoji-btn { font-size: 15px; padding: 5px 10px; }
.emoji-pop {
  position: absolute; left: 14px; bottom: calc(100% + 8px); z-index: 40;
  width: 300px; max-width: calc(100vw - 28px); max-height: 230px; overflow-y: auto;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
  padding: 8px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 14px 36px rgba(20, 28, 40, .18);
}
.emoji-item {
  border: none; background: none; font-size: 20px; line-height: 1.4;
  padding: 3px 0; border-radius: 6px; cursor: pointer;
}
.emoji-item:hover { background: #f2f6ff; }

/* ---------- 抽屉 ---------- */

.drawer-mask {
  position: fixed; inset: 0; background: rgba(18, 24, 34, .42);
  display: flex; justify-content: flex-end; z-index: 45;
}
.drawer {
  width: min(460px, 100vw); height: 100%; background: #fff;
  display: flex; flex-direction: column;
  box-shadow: -18px 0 50px rgba(18, 24, 34, .18);
  animation: drawer-in .18s ease;
}
#ticketDrawer .drawer { transition: width .18s ease; }
#ticketDrawer .drawer.detail-wide { width: min(780px, 100vw); }
@keyframes drawer-in { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes media-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes upload-spin { to { transform: rotate(360deg); } }
.drawer-head {
  flex: none;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: calc(18px + env(safe-area-inset-top)) 20px 14px; border-bottom: 1px solid var(--line);
}
.drawer-title { font-size: 18px; font-weight: 700; }
.drawer-sub { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.drawer-head-actions { display: flex; align-items: center; gap: 8px; }
.icon-close { border: none; background: none; font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 2px; }
.drawer-head .icon-close,
.modal-head .icon-close {
  width: 40px; height: 40px; margin: -8px -8px -8px 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 10px;
}
.drawer-head .icon-close:hover,
.modal-head .icon-close:hover { background: var(--panel-3); color: var(--text); }
.drawer-tabs { flex: none; display: flex; gap: 6px; padding: 10px 16px 0; border-bottom: 1px solid var(--line); }
.drawer-tab {
  flex: 1; border: none; background: none; padding: 10px 6px 12px; font-size: 14px; font-weight: 600;
  color: var(--muted); cursor: pointer; position: relative;
}
.drawer-tab.active { color: var(--theme); }
.drawer-tab.active::after {
  content: ""; position: absolute; left: 22%; right: 22%; bottom: 0; height: 3px;
  border-radius: 3px 3px 0 0; background: var(--theme);
}
.drawer-tab:disabled { opacity: .45; cursor: not-allowed; }
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px 30px; }

/* ---------- 工单 ---------- */

.ticket-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.ticket-filter {
  min-height: 34px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--muted);
  border-radius: 999px; padding: 6px 12px; font-size: 12.5px; cursor: pointer;
}
.ticket-filter:hover { border-color: var(--theme); color: var(--theme); }
.ticket-filter.active { background: var(--theme); border-color: var(--theme); color: #fff; font-weight: 600; }
.ticket-filter.active .ticket-filter-count { opacity: 1; }
.ticket-filter-count { margin-left: 3px; opacity: .85; }

.ticket-list { display: flex; flex-direction: column; gap: 10px; }
.ticket-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  cursor: pointer; background: #fff;
}
.ticket-card:hover { border-color: var(--theme); box-shadow: 0 4px 16px rgba(31,39,51,.05); }
.ticket-card.attention {
  border-color: #f3b3b7; background: #fff8f8;
  box-shadow: 0 0 0 3px rgba(229, 72, 77, .06);
}
.ticket-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ticket-card-top-left { display: flex; align-items: center; gap: 7px; min-width: 0; }
.ticket-no { font-size: 12px; color: var(--muted); letter-spacing: .2px; }
.ticket-unread-count {
  flex: none; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}
.ticket-card-title { font-weight: 600; margin: 7px 0 6px; line-height: 1.5; word-break: break-word; }
.ticket-card-preview {
  margin: -1px 0 7px; font-size: 12.5px; line-height: 1.55; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  word-break: break-word;
}
.ticket-card-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--muted); }
.ticket-alert-text { color: var(--danger); font-weight: 600; }

.status-pill {
  flex: none; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
  background: #f1f4f9; color: var(--muted); white-space: nowrap;
}
.status-pill.pending, .status-pill.waiting { background: #fdf3d7; color: var(--amber); }
.status-pill.processing { background: var(--theme-soft); color: var(--theme); }
.status-pill.awaiting_user { background: #fff2e0; color: #b45309; }
.status-pill.resolved, .status-pill.active { background: #e6f7ee; color: var(--green); }
.status-pill.closed { background: #eef0f4; color: #5b6472; }
.status-pill.invalid { background: #fde8e8; color: #b42318; }

.ticket-detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.ticket-supplement-request {
  margin: 10px 0 12px; padding: 12px 14px; border: 1px solid #f4d7a8;
  border-radius: 12px; background: #fffaf0;
}
.ticket-supplement-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ticket-supplement-title { font-size: 13px; font-weight: 700; color: #b45309; }
.ticket-supplement-time { font-size: 12px; color: var(--muted); flex: none; }
.ticket-supplement-content {
  margin-top: 8px; font-size: 14px; line-height: 1.7; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
}
.ticket-supplement-media { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.ticket-supplement-media img, .ticket-supplement-media video {
  width: 86px; height: 86px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line); background: #0f172a;
}
.ticket-supplement-media .attachment-item { width: 100%; }
.ticket-supplement-hint { margin-top: 9px; font-size: 12.5px; line-height: 1.6; color: #9a3412; }
.ticket-detail-tabs {
  display: flex; gap: 18px; margin: 0 0 12px; padding: 8px 0 0;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 6; background: #fff;
}
.ticket-detail-tab {
  border: none; background: none; padding: 7px 0 9px; font: inherit; font-size: 13.5px;
  font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent;
}
.ticket-detail-tab.active { color: var(--theme); border-bottom-color: var(--theme); }
.ticket-detail-layout { display: block; }
.ticket-detail-status { width: 100%; margin-bottom: 14px; }
.ticket-detail-content { width: 100%; min-width: 0; }
.ticket-status-card {
  border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
  background: #f8fbff;
}
.ticket-status-card.has-side {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, .9fr);
  gap: 14px 18px; align-items: start;
}
.ticket-status-main { min-width: 0; }
.ticket-status-side { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.ticket-status-label {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--muted);
}
.ticket-status-headline {
  margin-top: 7px; font-size: 15px; font-weight: 700; line-height: 1.5; color: var(--text);
  word-break: break-word;
}
.ticket-status-desc { margin-top: 7px; font-size: 12.5px; line-height: 1.65; color: var(--muted); }
.ticket-status-message {
  margin-top: 12px; padding: 10px 11px; background: #fff;
  border: 1px solid var(--line); border-radius: 10px;
}
.ticket-status-side .ticket-status-message { margin-top: 0; }
.ticket-status-unread {
  padding: 11px 12px; background: #fff8f8;
  border: 1px solid #f3b3b7; border-radius: 10px;
}
.ticket-status-unread-head { display: flex; align-items: center; gap: 7px; }
.ticket-status-unread-dot {
  flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--danger);
}
.ticket-status-unread-title { font-size: 12.5px; font-weight: 700; color: var(--danger); }
.ticket-status-unread-preview {
  margin-top: 6px; font-size: 12.5px; line-height: 1.6; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  word-break: break-word;
}
.ticket-status-unread-meta { margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.ticket-status-unread-btn { margin-top: 9px; width: auto; }
.ticket-status-message-label { font-size: 11.5px; font-weight: 700; color: var(--theme); }
.ticket-status-message-content {
  margin-top: 5px; font-size: 12.5px; line-height: 1.65; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
}
.ticket-status-message-time { margin-top: 7px; font-size: 11.5px; color: var(--muted); }
.ticket-status-media-hint { margin-top: 6px; font-size: 11.5px; line-height: 1.55; color: var(--muted); }
.ticket-status-card.awaiting_user { border-color: #f3d19b; background: #fffaf0; }
.ticket-status-card.awaiting_user .ticket-status-message-label { color: #b45309; }
.ticket-status-card.resolved { border-color: #b7e1c8; background: #f5fdf8; }
.ticket-status-card.resolved .ticket-status-message-label { color: var(--green); }
.ticket-status-card.closed, .ticket-status-card.invalid { background: #f7f9fc; }
.ticket-status-card.pending { border-color: #f3d19b; background: #fffaf0; }
.ticket-chat-summary { font-size: 12.5px; color: var(--muted); line-height: 1.7; margin-bottom: 10px; }
.ticket-chat-actions { margin-bottom: 12px; }
.ticket-chat-actions .primary-btn { width: auto; }
.ticket-chat-empty { padding: 28px 0; text-align: center; color: var(--muted); font-size: 13px; }
.ticket-detail-reply { margin-top: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fafcff; }
.ticket-detail-reply textarea, .ticket-rating textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font: inherit; resize: vertical; background: #fff; box-sizing: border-box;
}
.ticket-reply-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 9px 0; }
.ticket-reply-media { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.ticket-reply-media .thumb { position: relative; width: 72px; height: 72px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #f2f5fa; }
.ticket-reply-media .thumb img, .ticket-reply-media .thumb video { width: 100%; height: 100%; object-fit: cover; }
.ticket-reply-media .thumb button { position: absolute; right: 2px; top: 2px; border: none; background: rgba(0,0,0,.55); color: #fff; border-radius: 50%; width: 18px; height: 18px; cursor: pointer; line-height: 1; }
.ticket-reply-media .file-chip { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; font-size: 12px; }
.ticket-reply-media .file-chip button { border: none; background: none; color: var(--muted); cursor: pointer; }
.ticket-reply-media .file-progress { flex: 1 1 100%; min-width: 220px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #f7f9fc; }
.ticket-rating { margin-top: 8px; padding: 14px; border: 1px solid #f3e2b8; border-radius: 12px; background: #fffbf0; }
.ticket-rating textarea { background: #fff; margin-bottom: 10px; }
.rating-stars { display: flex; gap: 6px; margin-bottom: 10px; }
.rating-stars button {
  border: none; background: none; font-size: 28px; line-height: 1; cursor: pointer;
  color: #c9ced8; padding: 0 2px;
}
.rating-stars button.on { color: #d97706; }
.ticket-estimate { font-size: 12.5px; color: #1d4ed8; background: #eef4ff; border-radius: 8px; padding: 8px 10px; margin: 8px 0 12px; }
.ticket-estimate.overdue { background: #fff0f0; color: #b91c1c; }
.reply-item .reply-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.reply-item .reply-images img, .reply-item .reply-images video { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

.form-tip {
  font-size: 12.5px; color: var(--muted); line-height: 1.6;
  background: #f7f9fc; border-radius: 10px; padding: 10px 12px; margin-bottom: 16px;
}
.field { display: block; margin-bottom: 15px; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font: inherit; outline: none; background: #fbfcfe; resize: vertical;
}
.field input:focus, .field textarea:focus { border-color: var(--theme); background: #fff; }
.upload-area { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb { position: relative; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #0f172a; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .thumb-kind {
  position: absolute; left: 3px; bottom: 3px; padding: 1px 5px; border-radius: 5px;
  background: rgba(0,0,0,.6); color: #fff; font-size: 10px; pointer-events: none;
}
.thumb button {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border: none; border-radius: 50%;
  background: rgba(0,0,0,.6); color: #fff; font-size: 12px; line-height: 1; cursor: pointer;
}
.field select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font: inherit; outline: none; background: #fbfcfe; color: var(--text);
}
.field select:focus { border-color: var(--theme); background: #fff; }
.device-state { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin-bottom: 8px; }
.device-state.error { color: var(--danger); }
.device-tools { margin-bottom: 8px; }
.device-search {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px;
  font: inherit; font-size: 13px; outline: none; background: #fbfcfe;
}
.device-search:focus { border-color: var(--theme); background: #fff; }
.device-categories { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.device-category {
  display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 9px; background: #fff; color: var(--muted);
  font: inherit; font-size: 11.5px; line-height: 1.4; cursor: pointer;
}
.device-category.active { border-color: var(--theme); color: var(--theme); background: var(--theme-soft); }
.device-category-count { font-size: 10.5px; opacity: .75; }
.device-group-title { font-size: 11.5px; color: var(--muted); margin: 6px 1px 2px; }
.device-list { display: grid; grid-template-columns: 1fr; gap: 6px; max-height: 260px; overflow-y: auto; }
.device-option {
  display: flex; align-items: center; gap: 8px; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 9px; background: #fbfcfe; cursor: pointer; font-size: 13.5px; line-height: 1.4;
}
.device-option.checked { border-color: var(--theme); background: var(--theme-soft); }
.device-option input { width: 15px; height: 15px; margin: 0; accent-color: var(--theme); flex: none; }
.device-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.device-no {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; font-weight: 600; word-break: break-all;
}
.device-name { font-size: 11.5px; color: var(--muted); word-break: break-all; }
.device-type {
  max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 11px; color: var(--muted); background: #eef2f8; border-radius: 5px;
  padding: 2px 6px; flex: none;
}
.device-empty {
  padding: 12px 10px; text-align: center; font-size: 12.5px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 9px;
}
.device-refresh { margin-top: 8px; padding-left: 0; color: var(--theme); font-size: 12.5px; }
.attachment-list { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.attachment-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 9px; background: #fbfcfe; font-size: 13px; text-decoration: none; color: var(--text);
}
.attachment-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-size { font-size: 11.5px; color: var(--muted); flex: none; }
.attachment-download { color: var(--theme); font-size: 12px; flex: none; }
.attachment-del {
  width: 20px; height: 20px; border: none; border-radius: 50%; background: #eef0f4;
  color: var(--muted); font-size: 13px; line-height: 1; cursor: pointer; flex: none;
}
.attachment-del:hover { background: #e3e6ec; color: var(--danger); }
.form-hint { font-size: 13px; color: var(--muted); margin-top: 12px; line-height: 1.5; }
.form-hint.error { color: var(--danger); }
.form-hint.success { color: var(--green); }

.back-btn { padding-left: 0; color: var(--theme); margin-bottom: 12px; }
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.detail-title { font-size: 17px; font-weight: 700; margin: 10px 0 8px; line-height: 1.5; word-break: break-word; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.detail-content {
  font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word;
  background: #f7f9fc; border-radius: 10px; padding: 12px 14px;
}
.detail-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.detail-images img, .detail-images video {
  width: 86px; height: 86px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #0f172a;
}
.detail-attachments { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.detail-attachments:empty { display: none; }
.section-title { font-size: 13px; font-weight: 700; margin: 20px 0 10px; color: var(--text); }
.reply-item { border-left: 3px solid var(--theme-soft); padding: 2px 0 2px 10px; margin-bottom: 12px; }
.reply-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.reply-content { font-size: 14px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.timeline-item { position: relative; padding: 0 0 14px 16px; border-left: 2px solid var(--line); margin-left: 4px; }
.timeline-item:last-child { border-left-color: transparent; }
.timeline-item::before {
  content: ""; position: absolute; left: -5px; top: 4px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--theme);
}
.timeline-action { font-size: 13px; font-weight: 600; }
.timeline-meta { font-size: 12px; color: var(--muted); margin-top: 2px; line-height: 1.5; }

/* ---------- 历史对话 ---------- */

.history-list { display: flex; flex-direction: column; }
.history-card {
  padding: 13px 2px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.history-card:hover { background: #fafbfe; }
.history-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.history-type { font-weight: 600; font-size: 14px; }
.history-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.history-preview {
  font-size: 13px; color: var(--muted); margin-top: 5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-meta {
  font-size: 12px; color: var(--muted); line-height: 1.7;
  background: #f7f9fc; border-radius: 10px; padding: 10px 12px; margin-bottom: 14px;
}
.history-messages .msg-row { margin-bottom: 12px; }
.history-messages .msg-col { max-width: 84%; }

.empty-tip { text-align: center; color: var(--muted); font-size: 13px; padding: 46px 0; }

/* ---------- 弹窗 ---------- */

.modal-mask {
  position: fixed; inset: 0; background: rgba(18, 24, 34, .45);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 60;
}
.modal {
  width: 100%; max-width: 380px; background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,.25);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line); font-weight: 700;
}
.modal-body { padding: 18px; }
.modal-body .primary-btn { width: 100%; margin-top: 4px; }
.modal-tip { font-size: 12px; color: var(--muted); margin-top: 12px; text-align: center; line-height: 1.5; }

/* ---------- 提交工单向导 ---------- */

.ticket-wizard-mask { padding: 24px; z-index: 70; }
.ticket-wizard-modal {
  max-width: 640px; max-height: min(90vh, 860px); display: flex; flex-direction: column;
}
.ticket-wizard-modal .modal-head { flex: none; }
.wizard-steps {
  flex: none; display: flex; gap: 8px; padding: 14px 18px;
  border-bottom: 1px solid var(--line); background: #fbfcfe;
}
.wizard-step {
  flex: 1; display: flex; align-items: center; gap: 8px;
  min-width: 0; font-size: 13px; color: var(--muted);
}
.wizard-step-no {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: #fff;
  font-size: 12px; font-weight: 700;
}
.wizard-step.active { color: var(--text); font-weight: 600; }
.wizard-step.active .wizard-step-no { background: var(--theme); border-color: var(--theme); color: #fff; }
.wizard-step.done { color: var(--text); }
.wizard-step.done .wizard-step-no {
  background: rgba(34, 197, 94, .14); border-color: rgba(34, 197, 94, .4); color: #16a34a;
}
.wizard-body { flex: 1; overflow-y: auto; padding: 18px; }
.wizard-pane .field:first-child { margin-top: 0; }
.wizard-field-label {
  font-size: 13px; font-weight: 600; color: var(--text); margin: 2px 0 10px;
}
.wizard-type-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px;
}
.wizard-type-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 13px 12px; text-align: left; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff;
  color: var(--text); font: inherit;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.wizard-type-card:hover { border-color: var(--theme); }
.wizard-type-card:focus-visible { outline: 2px solid var(--theme); outline-offset: 2px; }
.wizard-type-card.active {
  border-color: var(--theme); background: var(--theme-soft);
  box-shadow: 0 0 0 1px var(--theme) inset;
}
.wizard-type-icon {
  width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--theme); line-height: 1.2;
}
.wizard-type-icon svg { width: 22px; height: 22px; stroke-width: 1.9; }
.wizard-type-title { font-size: 13px; font-weight: 600; line-height: 1.35; }
.wizard-type-desc { font-size: 11px; color: var(--muted); line-height: 1.45; }
.ticket-selfheal-tip {
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: 12px; padding: 11px 12px;
  border: 1px solid rgba(26, 115, 232, .18); border-radius: 12px;
  background: linear-gradient(135deg, rgba(26, 115, 232, .06), rgba(26, 115, 232, .02));
}
.ticket-selfheal-icon {
  flex: none; width: 30px; height: 30px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--theme-soft); color: var(--theme);
}
.ticket-selfheal-icon svg { width: 17px; height: 17px; stroke-width: 2; }
.ticket-selfheal-text { flex: 1; min-width: 0; }
.ticket-selfheal-text strong { display: block; font-size: 13px; line-height: 1.5; color: var(--text); }
.ticket-selfheal-text p { margin: 3px 0 0; font-size: 12px; line-height: 1.55; color: var(--muted); }
.ticket-selfheal-btn { flex: none; width: auto; margin-top: 0; white-space: nowrap; }
.tool-icon { display: inline-flex; align-items: center; justify-content: center; margin-right: 5px; vertical-align: -2px; }
.tool-icon svg { width: 15px; height: 15px; stroke-width: 2; }
.wizard-summary {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 14px; margin-bottom: 16px;
  border: 1px solid var(--line); border-radius: 12px; background: #fbfcfe;
}
.wizard-summary-row { display: flex; gap: 12px; font-size: 13px; line-height: 1.6; }
.wizard-summary-label { flex: none; width: 76px; color: var(--muted); }
.wizard-summary-value { flex: 1; min-width: 0; color: var(--text); word-break: break-word; white-space: pre-wrap; }
.wizard-hint { margin: 0; padding: 10px 18px 0; }
.wizard-hint:empty { display: none; }
.wizard-foot {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-top: 1px solid var(--line);
}
.wizard-foot-spacer { flex: 1; }
.wizard-foot .primary-btn, .wizard-foot .ghost-btn { width: auto; min-width: 88px; margin-top: 0; }

[data-theme="dark"] .ticket-wizard-modal { background: var(--panel); }
[data-theme="dark"] .wizard-steps { background: var(--panel-2); }
[data-theme="dark"] .wizard-step-no { background: var(--panel-3); }
[data-theme="dark"] .wizard-step.active .wizard-step-no { background: var(--theme); border-color: var(--theme); }
[data-theme="dark"] .wizard-step.done .wizard-step-no {
  background: rgba(34, 197, 94, .18); border-color: rgba(34, 197, 94, .45); color: var(--green);
}
[data-theme="dark"] .wizard-summary { background: var(--panel-2); }
[data-theme="dark"] .wizard-type-card { background: var(--panel-2); }
[data-theme="dark"] .wizard-type-card.active { background: rgba(56, 132, 255, .16); }
[data-theme="dark"] .ticket-selfheal-tip {
  background: rgba(56, 132, 255, .09); border-color: rgba(56, 132, 255, .24);
}
[data-theme="dark"] .ticket-selfheal-icon { background: rgba(56, 132, 255, .18); }

/* ---------- 常见问题 ---------- */

.faq-mask { padding: 24px; z-index: 65; }
.faq-modal {
  max-width: 760px; max-height: min(86vh, 820px);
  display: flex; flex-direction: column;
}
.faq-modal .modal-head { flex: none; }
.faq-toolbar { flex: none; padding: 14px 18px 0; }
.faq-toolbar input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font: inherit; outline: none; background: #fbfcfe; color: var(--text);
}
.faq-toolbar input:focus { border-color: var(--theme); background: #fff; }
.faq-cats {
  flex: none; display: flex; gap: 8px; overflow-x: auto; padding: 12px 18px;
  border-bottom: 1px solid var(--line); scrollbar-width: none;
}
.faq-cats::-webkit-scrollbar { display: none; }
.faq-cat {
  flex: none; border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
  white-space: nowrap; font: inherit; font-size: 12.5px;
}
.faq-cat:hover { border-color: var(--theme); color: var(--theme); }
.faq-cat.active { background: var(--theme); border-color: var(--theme); color: #fff; }
.faq-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px 18px 18px; }
.faq-cat-desc { font-size: 12.5px; color: var(--muted); line-height: 1.6; margin-bottom: 12px; }
.faq-list { display: flex; flex-direction: column; gap: 8px; }
.faq-item { border: 1px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden; }
.faq-item.open { border-color: var(--theme); }
.faq-question {
  width: 100%; display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px;
  border: none; background: none; text-align: left; cursor: pointer; font: inherit; color: var(--text);
}
.faq-q-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.faq-q-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.faq-q-title { font-size: 13.5px; font-weight: 600; line-height: 1.5; }
.faq-q-cat {
  font-size: 10.5px; color: var(--theme); background: var(--theme-soft);
  padding: 1px 7px; border-radius: 999px;
}
.faq-q-desc { font-size: 12px; color: var(--muted); line-height: 1.5; }
.faq-chevron { flex: none; color: var(--muted); font-size: 14px; transition: transform .15s; margin-top: 2px; }
.faq-item.open .faq-chevron { transform: rotate(180deg); }
.faq-answer { border-top: 1px dashed var(--line); padding: 12px 14px; background: #fbfcfe; }
.faq-answer-inner { font-size: 13px; line-height: 1.75; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.faq-empty { padding: 36px 10px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.7; }
.faq-foot {
  flex: none; display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 12px 18px; border-top: 1px solid var(--line);
}
.faq-foot-text { margin-right: auto; font-size: 12.5px; color: var(--muted); }
.faq-foot .primary-btn, .faq-foot .ghost-btn { width: auto; margin-top: 0; }

[data-theme="dark"] .faq-modal { background: var(--panel); }
[data-theme="dark"] .faq-toolbar input { background: var(--panel-2); color: var(--text); }
[data-theme="dark"] .faq-toolbar input:focus { background: var(--panel-3); }
[data-theme="dark"] .faq-cat { background: var(--panel-2); color: var(--text); }
[data-theme="dark"] .faq-cat.active { background: var(--theme); border-color: var(--theme); color: #fff; }
[data-theme="dark"] .faq-item { background: var(--panel-2); }
[data-theme="dark"] .faq-answer { background: var(--panel-3); }
[data-theme="dark"] .welcome-guide-item { background: var(--panel-2); }
[data-theme="dark"] .welcome-guide-icon { background: rgba(56, 132, 255, .16); }
[data-theme="dark"] .model-card { background: var(--panel-2); }
[data-theme="dark"] .model-card-head { background: rgba(56, 132, 255, .08); }
[data-theme="dark"] .model-tier.high { background: rgba(34, 197, 94, .16); color: #7ee2a8; }
[data-theme="dark"] .model-tier.mid { background: rgba(234, 179, 8, .16); color: #f5cf6b; }
[data-theme="dark"] .model-tier.low { background: var(--panel-3); color: var(--muted); }
.faq-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.faq-action {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 8px; padding: 6px 12px; font: inherit; font-size: 12.5px; cursor: pointer;
}
.faq-action:hover { border-color: var(--theme); color: var(--theme); }
.faq-action.primary { background: var(--theme); border-color: var(--theme); color: #fff; }
.faq-action.primary:hover { color: #fff; filter: brightness(1.05); }

/* 在售机型配置卡片：AI 回复与常见问题共用 */
.model-card {
  width: 100%; margin-top: 10px; border: 1px solid var(--line); border-radius: 14px;
  background: #fff; overflow: hidden; text-align: left;
}
.model-card-head {
  padding: 11px 13px; border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(26, 115, 232, .06), rgba(26, 115, 232, .015));
}
.model-card-title { font-size: 13.5px; font-weight: 700; color: var(--text); }
.model-card-sub { margin-top: 2px; font-size: 12px; color: var(--muted); }
.model-card-list { display: flex; flex-direction: column; }
.model-item { padding: 11px 13px; border-top: 1px dashed var(--line); }
.model-item[hidden] { display: none; }
.model-item:first-child { border-top: 0; }
.model-item-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.model-name { font-size: 14px; color: var(--text); }
.model-tier {
  font-size: 11px; line-height: 1.4; padding: 2px 7px; border-radius: 999px;
  background: #eef1f6; color: #667085; white-space: nowrap;
}
.model-tier.high { background: #e6f7ee; color: #0b6b3a; }
.model-tier.mid { background: #fdf3d7; color: #a16207; }
.model-tier.low { background: #eef1f6; color: #667085; }
.model-pos {
  font-size: 11px; line-height: 1.4; padding: 2px 7px; border-radius: 999px;
  background: var(--theme-soft); color: var(--theme); white-space: nowrap;
}
.model-specs {
  display: flex; flex-wrap: wrap; gap: 3px 12px; margin-top: 6px;
  font-size: 12.5px; line-height: 1.6; color: var(--muted);
}
.model-spec b { color: var(--text); font-weight: 600; }
.model-detail { margin: 5px 0 0; font-size: 12.5px; line-height: 1.65; color: var(--muted); }
.model-detail b { color: var(--text); font-weight: 600; }
.model-card-toggle {
  display: block; width: 100%; padding: 10px 13px; border: 0; border-top: 1px solid var(--line);
  background: var(--panel-2); color: var(--theme); font: inherit; font-size: 12.5px; font-weight: 600;
  cursor: pointer; text-align: center;
}
.model-card-toggle:hover { background: var(--theme-soft); }
.msg-col .model-card { width: 100%; }

/* 自助换机卡片：AI 回复与常见问题共用 */
.swap-card {
  width: 100%; margin-top: 10px; border: 1px solid var(--line); border-radius: 14px;
  background: #fff; overflow: hidden; text-align: left;
}
.swap-card-head {
  padding: 11px 13px; border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(26, 115, 232, .07), rgba(26, 115, 232, .015));
}
.swap-card-title { font-size: 13.5px; font-weight: 700; color: var(--text); }
.swap-card-sub { margin-top: 2px; font-size: 12px; color: var(--muted); }
.swap-card-body { padding: 11px 13px 4px; }
.swap-card-text { margin: 0; font-size: 12.5px; line-height: 1.65; color: var(--muted); }
.swap-card-actions { display: flex; gap: 8px; padding: 10px 13px 13px; }
.swap-card-btn {
  flex: 1; border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 12.5px; cursor: pointer;
}
.swap-card-btn:hover { border-color: var(--theme); color: var(--theme); }
.swap-card-btn.primary { background: var(--theme); border-color: var(--theme); color: #fff; }
.swap-card-btn.primary:hover { color: #fff; filter: brightness(1.05); }
.msg-col .swap-card { width: 100%; }
.swap-confirm-hint { margin-top: 14px; margin-bottom: 0; }
[data-theme="dark"] .swap-card { background: var(--panel-2); }
[data-theme="dark"] .swap-card-head { background: rgba(56, 132, 255, .08); }
[data-theme="dark"] .swap-card-btn { background: var(--panel); }

/* ---------- 云机自助恢复 ---------- */

.selfheal-mask { padding: 24px; z-index: 75; }
.selfheal-modal {
  max-width: 560px; max-height: min(88vh, 760px);
  display: flex; flex-direction: column;
}
.selfheal-modal .modal-head { flex: none; }
.selfheal-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 18px 18px; }
.selfheal-hint { font-size: 13px; line-height: 1.65; color: var(--muted); margin: 0 0 12px; }
.selfheal-pane[data-step="device"] .device-list { max-height: 300px; }
.selfheal-choices { display: flex; flex-direction: column; gap: 8px; }
.selfheal-choice {
  display: flex; align-items: flex-start; gap: 12px; width: 100%;
  border: 1px solid var(--line); background: #fbfcfe; color: var(--text);
  border-radius: 12px; padding: 13px 14px; text-align: left; font: inherit; cursor: pointer;
}
.selfheal-choice:hover { border-color: var(--theme); }
.selfheal-choice.active { border-color: var(--theme); background: var(--theme-soft); }
.selfheal-choice-icon {
  flex: none; width: 32px; height: 32px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: #eef2f8; color: var(--muted); font-weight: 700;
}
.selfheal-choice.active .selfheal-choice-icon { background: var(--theme); color: #fff; }
.selfheal-choice-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.selfheal-choice-text b { font-size: 13.5px; line-height: 1.5; }
.selfheal-choice-text small { font-size: 12px; line-height: 1.5; color: var(--muted); }
.selfheal-actions { display: flex; gap: 10px; margin-top: 16px; }
.selfheal-actions .primary-btn, .selfheal-actions .ghost-btn { flex: 1; width: auto; margin-top: 0; }
.selfheal-spinner {
  width: 38px; height: 38px; margin: 26px auto 18px;
  border: 3px solid var(--line); border-top-color: var(--theme);
  border-radius: 50%; animation: upload-spin .8s linear infinite;
}
.selfheal-result-icon {
  width: 46px; height: 46px; margin: 20px auto 14px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800;
}
.selfheal-result-icon.success { background: #e6f7ee; color: var(--green); }
.selfheal-result-icon.fail { background: #fde8e8; color: #b42318; }
.selfheal-result-icon.info { background: var(--theme-soft); color: var(--theme); }
.selfheal-result-title { margin: 0 0 8px; font-size: 17px; text-align: center; }
.selfheal-result-message {
  margin: 0 auto; max-width: 440px; text-align: center;
  font-size: 13px; line-height: 1.7; color: var(--muted);
  white-space: pre-wrap; word-break: break-word;
}
.selfheal-foot {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-top: 1px solid var(--line);
}
.selfheal-foot-spacer { flex: 1; }
.selfheal-foot .primary-btn, .selfheal-foot .ghost-btn { width: auto; margin-top: 0; }

[data-theme="dark"] .selfheal-modal { background: var(--panel); }
[data-theme="dark"] .selfheal-choice { background: var(--panel-2); }
[data-theme="dark"] .selfheal-choice-icon { background: var(--panel-3); }
[data-theme="dark"] .selfheal-choice.active { background: rgba(56, 132, 255, .16); }
[data-theme="dark"] .selfheal-result-icon.success { background: rgba(34, 197, 94, .16); }
[data-theme="dark"] .selfheal-result-icon.fail { background: rgba(255, 122, 127, .14); }
[data-theme="dark"] .faq-action { background: var(--panel-2); color: var(--text); }
[data-theme="dark"] .faq-action.primary { background: var(--theme); border-color: var(--theme); color: #fff; }
[data-theme="dark"] .ghost-btn { background: var(--panel-2); color: var(--text); border-color: var(--line); }
[data-theme="dark"] .ghost-btn:hover { color: var(--theme); border-color: var(--theme); }

.msg-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.msg-action {
  border: 1px solid var(--line); background: #fff; color: var(--theme);
  border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 12px;
  line-height: 1.4; cursor: pointer;
}
.msg-action:hover { border-color: var(--theme); }
.msg-action.primary { background: var(--theme); border-color: var(--theme); color: #fff; }
[data-theme="dark"] .msg-action { background: var(--panel-2); color: var(--text); border-color: var(--line); }
[data-theme="dark"] .msg-action.primary { background: var(--theme); color: #fff; }

.msg-suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.msg-suggestion {
  border: 1px dashed var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 12px;
  line-height: 1.4; text-align: left; cursor: pointer;
}
.msg-suggestion:hover { border-color: var(--theme); color: var(--theme); background: var(--theme-soft); }
[data-theme="dark"] .msg-suggestion { background: var(--panel-2); color: var(--muted); border-color: var(--line); }
[data-theme="dark"] .msg-suggestion:hover { background: var(--theme-soft); color: var(--theme); border-color: var(--theme); }

.msg-feedback, .faq-feedback {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 8px; color: var(--muted); font-size: 12px;
}
.feedback-label { line-height: 1.4; }
.feedback-btn, .feedback-reason {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 999px; padding: 3px 9px; font: inherit; font-size: 12px;
  line-height: 1.4; cursor: pointer;
}
.feedback-btn:hover, .feedback-reason:hover { border-color: var(--theme); color: var(--theme); }
.feedback-reasons { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.feedback-thanks { color: var(--muted); }
[data-theme="dark"] .feedback-btn, [data-theme="dark"] .feedback-reason { background: var(--panel-2); color: var(--muted); border-color: var(--line); }
[data-theme="dark"] .feedback-btn:hover, [data-theme="dark"] .feedback-reason:hover { color: var(--theme); border-color: var(--theme); }


.toast {
  position: fixed; left: 50%; bottom: 44px; transform: translateX(-50%);
  background: rgba(28, 34, 44, .92); color: #fff; font-size: 13px;
  padding: 10px 16px; border-radius: 10px; z-index: 80; max-width: 82vw; line-height: 1.5;
}
[hidden] { display: none !important; }

@media (max-width: 1100px) {
  .app { max-width: 860px; }
  .desktop-side { display: none; }
}

@media (max-width: 760px) {
  .ticket-detail-status { margin-bottom: 12px; }
  .ticket-status-card.has-side { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .ticket-wizard-mask { padding: 10px; }
  .ticket-wizard-modal { max-height: 94vh; border-radius: 14px; }
  .wizard-steps { padding: 12px 14px; gap: 4px; }
  .wizard-step { gap: 5px; font-size: 12px; }
  .wizard-step-no { width: 22px; height: 22px; }
  .wizard-body { padding: 14px; }
  .wizard-type-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .wizard-type-card { padding: 11px 10px; }
  .wizard-type-desc { font-size: 11.5px; line-height: 1.45; }
  .ticket-selfheal-tip { flex-wrap: wrap; }
  .ticket-selfheal-text { flex-basis: calc(100% - 40px); }
  .ticket-selfheal-btn { width: calc(100% - 40px); margin-left: 40px; }
  .wizard-foot { padding: 12px 14px; gap: 8px; }
  .wizard-foot .primary-btn, .wizard-foot .ghost-btn { min-width: 0; padding-left: 14px; padding-right: 14px; }
  .faq-mask { padding: 10px; }
  .faq-modal { max-height: 92vh; border-radius: 14px; }
  .faq-toolbar { padding: 12px 14px 0; }
  .faq-cats { padding: 10px 14px; }
  .faq-body { padding: 12px 14px 14px; }
  .faq-q-desc { display: none; }
  .faq-foot { padding: 10px 14px; gap: 8px; flex-wrap: wrap; }
  .faq-foot-text { flex-basis: 100%; margin-right: 0; }
  .faq-foot .primary-btn, .faq-foot .ghost-btn { flex: 1; }
  .selfheal-mask { padding: 10px; }
  .selfheal-modal { max-height: 92vh; border-radius: 14px; }
  .selfheal-body { padding: 14px; }
  .selfheal-foot { padding: 10px 14px; }
  .selfheal-actions { flex-direction: column; }
  .selfheal-actions .primary-btn, .selfheal-actions .ghost-btn { width: 100%; }
}

@media (max-width: 720px) {
  .app { box-shadow: none; }
  .topbar {
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
    flex-wrap: nowrap; gap: 8px;
  }
  .brand { flex: 1; min-width: 0; font-size: 14px; gap: 8px; }
  .brand-dot { width: 10px; height: 10px; }
  .user-area { width: auto; flex: none; flex-wrap: nowrap; justify-content: flex-end; gap: 6px; }
  .user-area > .status-badge,
  .user-area > .theme-btn,
  .user-area > #notifyBtn,
  .user-area > #historyBtn,
  .user-area > #linkedTicketBtn,
  .user-area > #userChip { display: none; }
  .user-area > .primary-btn.sm { min-height: 36px; padding: 8px 10px; font-size: 12.5px; white-space: nowrap; }
  .user-area > .action-btn { min-height: 36px; padding: 8px 9px; font-size: 12.5px; white-space: nowrap; }
  .more-wrap { display: block; }
  .service-identity { padding: 6px 12px; gap: 8px; }
  .service-avatar { width: 28px; height: 28px; border-radius: 8px; font-size: 10px; }
  .service-title { font-size: 12.5px; }
  .service-sub { display: none; }
  .service-status { font-size: 10px; padding: 2px 7px; }
  .chat-tabs { padding: 0 8px; }
  .chat-tab { max-width: 190px; padding: 9px 7px 7px; }
  .chat-tab-label { max-width: 110px; }
  .chat-tab-meta { display: none; }
  .status-badge { padding: 4px 8px; }
  .primary-btn.sm { padding: 7px 10px; }
  .action-btn { padding: 7px 9px; }
  .alert-banner { padding: 8px 10px; gap: 8px; }
  .alert-banner-text { white-space: normal; }
  .alert-banner .primary-btn.sm { padding: 7px 10px; }
  .chat-scroll { padding: 12px 12px 6px; }
  .welcome { margin-top: 18px; }
  .welcome-title { font-size: 17px; }
  .msg-col { max-width: 84%; }
  .msg-suggestion { min-height: 32px; padding: 6px 10px; }
  .state-bar { padding: 8px 12px; gap: 6px 8px; font-size: 12.5px; }
  .state-bar .state-text { flex-basis: 100%; min-width: 0; }
  .state-bar .link-btn { min-height: 34px; padding: 6px 8px; }
  .state-hint { font-size: 11.5px; }
  .composer { padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); gap: 6px; }
  .composer textarea { min-height: 56px; max-height: 140px; padding: 10px 12px; border-radius: 11px; }
  .composer-toolbar { gap: 4px; }
  .composer-toolbar .tool-btn { min-height: 30px; padding: 5px 8px; font-size: 12px; }
  .send-btn { min-height: 40px; padding: 9px 15px; border-radius: 11px; }
  .ticket-filter { min-height: 36px; padding: 6px 12px; }
  .drawer { width: 100vw; }
  .drawer-head { padding: calc(14px + env(safe-area-inset-top)) 16px 12px; }
  .drawer-body { padding: 14px 16px 26px; }
}

/* ---------- 夜间模式 ---------- */

[data-theme="dark"] {
  color-scheme: dark;
  --theme: #6ea8ff;
  --theme-strong: #2563eb;
  --theme-soft: rgba(110, 168, 255, .16);
  --bg: #0b0f16;
  --panel: #111722;
  --panel-2: #0d131d;
  --panel-3: #172030;
  --panel-4: #1c2637;
  --panel-tint: rgba(79, 140, 255, .14);
  --text: #e8edf5;
  --muted: #96a3b8;
  --line: #263244;
  --line-strong: #344258;
  --danger: #ff7a7f;
  --green: #4ade80;
  --amber: #fbbf24;
  --shadow: 0 8px 30px rgba(0, 0, 0, .45);
  --shadow-color: rgba(0, 0, 0, .5);
  --overlay: rgba(0, 0, 0, .62);
}
[data-theme="dark"] body {
  background:
    radial-gradient(1100px 560px at 50% -12%, var(--theme-soft), transparent 62%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
}
[data-theme="dark"] .app { background: var(--panel); box-shadow: var(--shadow); }
[data-theme="dark"] .topbar { background: rgba(17, 23, 34, .97); }
[data-theme="dark"] .desktop-side { background: var(--panel-2); border-left-color: var(--line); }
[data-theme="dark"] .side-card { background: var(--panel); border-color: var(--line); }
[data-theme="dark"] .side-service-status.tone-active { background: rgba(34, 197, 94, .16); color: var(--green); }
[data-theme="dark"] .side-service-status.tone-waiting { background: rgba(245, 158, 11, .16); color: var(--amber); }
[data-theme="dark"] .side-service-status.tone-held,
[data-theme="dark"] .side-service-status.tone-ticket { background: rgba(245, 158, 11, .16); color: #fdba74; }
[data-theme="dark"] .side-service-status.tone-ended { background: var(--panel-4); color: var(--muted); }
[data-theme="dark"] .side-action { background: var(--panel-3); color: var(--text); }
[data-theme="dark"] .side-action:hover { background: var(--theme-soft); color: var(--theme); }
[data-theme="dark"] .more-menu { background: var(--panel); border-color: var(--line); box-shadow: 0 18px 44px rgba(0, 0, 0, .5); }
[data-theme="dark"] .more-user { border-bottom-color: var(--line); }
[data-theme="dark"] .more-item:hover { background: var(--panel-3); color: var(--theme); }
[data-theme="dark"] .more-item.danger:hover { background: rgba(255, 122, 127, .12); color: var(--danger); }
[data-theme="dark"] .drawer-head .icon-close:hover,
[data-theme="dark"] .modal-head .icon-close:hover { background: var(--panel-3); color: var(--text); }
[data-theme="dark"] .status-badge { background: var(--panel-4); color: var(--muted); }
[data-theme="dark"] .status-badge.online { background: rgba(34, 197, 94, .14); color: var(--green); }
[data-theme="dark"] .status-badge.offline { background: rgba(245, 158, 11, .14); color: var(--amber); }
[data-theme="dark"] .action-btn { background: var(--panel-2); color: var(--text); border-color: var(--line); }
[data-theme="dark"] .action-btn:hover { border-color: var(--theme); color: var(--theme); }
[data-theme="dark"] .action-btn:disabled { background: var(--panel-2); }
[data-theme="dark"] .action-btn:disabled:hover { border-color: var(--line); color: var(--text); }
[data-theme="dark"] .count-badge { background: var(--theme-strong); }
[data-theme="dark"] .count-badge.alert,
[data-theme="dark"] .chat-tab-unread,
[data-theme="dark"] .ticket-unread-count { background: #b91c1c; color: #fff; }
[data-theme="dark"] .alert-banner {
  background: linear-gradient(90deg, rgba(245, 158, 11, .16), rgba(245, 158, 11, .06));
  border-bottom-color: rgba(245, 158, 11, .35);
  border-left-color: #f59e0b;
}
[data-theme="dark"] .alert-banner-title { color: #fcd34d; }
[data-theme="dark"] .alert-banner-text { color: #fbbf24; }
[data-theme="dark"] .alert-banner-icon { background: #f59e0b; color: #1f1300; }
[data-theme="dark"] .alert-banner .icon-close { color: #fbbf24; }
[data-theme="dark"] .alert-banner .primary-btn.sm { background: #f59e0b; color: #1f1300; }
[data-theme="dark"] .chat-tabs { background: var(--panel); }
[data-theme="dark"] .chat-tab:hover { background: var(--panel-3); }
[data-theme="dark"] .service-identity { background: var(--panel-3); }
[data-theme="dark"] .service-identity.mode-ai { background: rgba(79, 140, 255, .10); }
[data-theme="dark"] .service-identity.mode-human { background: rgba(34, 197, 94, .10); }
[data-theme="dark"] .service-identity.mode-ticket { background: rgba(245, 158, 11, .10); }
[data-theme="dark"] .service-identity.mode-ended { background: var(--panel-3); }
[data-theme="dark"] .service-identity.mode-human .service-avatar { background: rgba(34, 197, 94, .18); color: var(--green); }
[data-theme="dark"] .service-identity.mode-ticket .service-avatar { background: rgba(245, 158, 11, .18); color: var(--amber); }
[data-theme="dark"] .service-identity.mode-ended .service-avatar { background: var(--panel-4); color: var(--muted); }
[data-theme="dark"] .service-status.tone-active { background: rgba(34, 197, 94, .16); color: var(--green); }
[data-theme="dark"] .service-status.tone-waiting { background: rgba(245, 158, 11, .16); color: var(--amber); }
[data-theme="dark"] .service-status.tone-held,
[data-theme="dark"] .service-status.tone-ticket { background: rgba(245, 158, 11, .16); color: #fdba74; }
[data-theme="dark"] .service-status.tone-ended { background: var(--panel-4); color: var(--muted); }
[data-theme="dark"] .chat-scroll { background: var(--bg); }
[data-theme="dark"] .quick-chip { background: var(--panel-3); color: var(--text); border-color: var(--line); }
[data-theme="dark"] .quick-chip:hover { background: var(--theme-soft); color: var(--theme); border-color: var(--theme); }
[data-theme="dark"] .bubble { background: var(--panel-4); color: var(--text); }
[data-theme="dark"] .msg-row.mine .bubble { background: var(--theme-strong); }
[data-theme="dark"] .msg-row .bubble.media-bubble,
[data-theme="dark"] .msg-row.mine .bubble.media-bubble,
[data-theme="dark"] .msg-row .bubble.file-bubble,
[data-theme="dark"] .msg-row.mine .bubble.file-bubble { background: var(--panel-4); color: var(--text); }
[data-theme="dark"] .media-wrap { background: var(--panel-4); }
[data-theme="dark"] .media-skeleton {
  background: linear-gradient(100deg, #1c2637 20%, #253247 40%, #1c2637 60%);
  color: var(--muted);
}
[data-theme="dark"] .media-wrap.failed .media-skeleton { background: rgba(229, 72, 77, .14); color: var(--danger); }
[data-theme="dark"] .file-card { background: var(--panel-2); color: var(--text); }
[data-theme="dark"] .file-progress .upload-bar { background: var(--line-strong); }
[data-theme="dark"] .system-msg span { background: var(--panel-3); color: var(--muted); }
[data-theme="dark"] .state-bar { background: var(--panel-2); }
[data-theme="dark"] .state-bar.active { background: rgba(34, 197, 94, .12); }
[data-theme="dark"] .state-bar.held,
[data-theme="dark"] .state-bar.hold-pending,
[data-theme="dark"] .state-bar.offline,
[data-theme="dark"] .state-bar.offline-wait {
  background: rgba(245, 158, 11, .12);
  border-top-color: rgba(245, 158, 11, .35);
}
[data-theme="dark"] .state-bar.closed { background: var(--panel-3); }
[data-theme="dark"] .state-bar .hold-accept { color: var(--amber); }
[data-theme="dark"] .composer { background: var(--panel); }
[data-theme="dark"] .composer textarea,
[data-theme="dark"] .composer textarea:focus { background: var(--panel-2); color: var(--text); border-color: var(--line); }
[data-theme="dark"] .primary-btn,
[data-theme="dark"] .send-btn { background: var(--theme-strong); }
[data-theme="dark"] .tool-btn { background: var(--panel-2); color: var(--muted); border-color: var(--line); }
[data-theme="dark"] .composer-toolbar .tool-btn { background: var(--panel-3); color: var(--muted); }
[data-theme="dark"] .composer-toolbar .tool-btn:hover:not(:disabled) {
  background: var(--panel-4); color: var(--theme); border-color: var(--line-strong);
}
[data-theme="dark"] .emoji-pop { background: var(--panel); box-shadow: var(--shadow); }
[data-theme="dark"] .emoji-item:hover { background: var(--panel-3); }
[data-theme="dark"] .drawer-mask,
[data-theme="dark"] .modal-mask { background: var(--overlay); }
[data-theme="dark"] .drawer,
[data-theme="dark"] .modal {
  background: var(--panel); color: var(--text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
}
[data-theme="dark"] .ticket-card { background: var(--panel-2); }
[data-theme="dark"] .ticket-filter.active { background: var(--theme-strong); border-color: var(--theme-strong); color: #fff; }
[data-theme="dark"] .ticket-card:hover { box-shadow: 0 4px 16px rgba(0, 0, 0, .35); }
[data-theme="dark"] .ticket-card.attention {
  background: rgba(229, 72, 77, .10);
  border-color: rgba(229, 72, 77, .45);
  box-shadow: 0 0 0 3px rgba(229, 72, 77, .10);
}
[data-theme="dark"] .status-pill { background: var(--panel-4); color: var(--muted); }
[data-theme="dark"] .status-pill.pending,
[data-theme="dark"] .status-pill.waiting { background: rgba(245, 158, 11, .16); color: var(--amber); }
[data-theme="dark"] .status-pill.processing { background: var(--theme-soft); color: var(--theme); }
[data-theme="dark"] .status-pill.awaiting_user { background: rgba(245, 158, 11, .16); color: #fdba74; }
[data-theme="dark"] .status-pill.resolved,
[data-theme="dark"] .status-pill.active { background: rgba(34, 197, 94, .16); color: var(--green); }
[data-theme="dark"] .status-pill.closed { background: var(--panel-4); color: var(--muted); }
[data-theme="dark"] .status-pill.invalid { background: rgba(229, 72, 77, .16); color: var(--danger); }
[data-theme="dark"] .ticket-supplement-request {
  background: rgba(245, 158, 11, .08);
  border-color: rgba(245, 158, 11, .35);
}
[data-theme="dark"] .ticket-supplement-title { color: var(--amber); }
[data-theme="dark"] .ticket-supplement-hint { color: #fdba74; }
[data-theme="dark"] .ticket-detail-tabs { background: var(--panel); }
[data-theme="dark"] .ticket-status-card { background: var(--panel-2); }
[data-theme="dark"] .ticket-status-card.awaiting_user,
[data-theme="dark"] .ticket-status-card.pending {
  background: rgba(245, 158, 11, .08);
  border-color: rgba(245, 158, 11, .35);
}
[data-theme="dark"] .ticket-status-card.awaiting_user .ticket-status-message-label { color: var(--amber); }
[data-theme="dark"] .ticket-status-card.resolved {
  background: rgba(34, 197, 94, .08);
  border-color: rgba(34, 197, 94, .30);
}
[data-theme="dark"] .ticket-status-card.closed,
[data-theme="dark"] .ticket-status-card.invalid { background: var(--panel-3); }
[data-theme="dark"] .ticket-status-message { background: var(--panel-3); }
[data-theme="dark"] .ticket-status-unread {
  background: rgba(229, 72, 77, .10);
  border-color: rgba(229, 72, 77, .40);
}
[data-theme="dark"] .ticket-detail-reply { background: var(--panel-2); }
[data-theme="dark"] .ticket-detail-reply textarea,
[data-theme="dark"] .ticket-rating textarea {
  background: var(--panel-2); color: var(--text); border-color: var(--line);
}
[data-theme="dark"] .ticket-reply-media .thumb { background: var(--panel-4); }
[data-theme="dark"] .ticket-reply-media .file-chip { background: var(--panel-2); color: var(--text); }
[data-theme="dark"] .ticket-reply-media .file-progress { background: var(--panel-3); }
[data-theme="dark"] .ticket-rating {
  background: rgba(245, 158, 11, .07);
  border-color: rgba(245, 158, 11, .30);
}
[data-theme="dark"] .ticket-estimate { background: rgba(79, 140, 255, .12); color: var(--theme); }
[data-theme="dark"] .ticket-estimate.overdue { background: rgba(229, 72, 77, .12); color: var(--danger); }
[data-theme="dark"] .form-tip { background: var(--panel-3); }
[data-theme="dark"] .field input,
[data-theme="dark"] .field textarea,
[data-theme="dark"] .field select,
[data-theme="dark"] .field input:focus,
[data-theme="dark"] .field textarea:focus,
[data-theme="dark"] .field select:focus,
[data-theme="dark"] .device-search,
[data-theme="dark"] .device-search:focus,
[data-theme="dark"] .device-option,
[data-theme="dark"] .attachment-item {
  background: var(--panel-2); color: var(--text); border-color: var(--line);
}
[data-theme="dark"] .device-category {
  background: var(--panel-2); color: var(--muted); border-color: var(--line);
}
[data-theme="dark"] .device-category.active {
  background: var(--theme-soft); color: var(--theme); border-color: var(--theme);
}
[data-theme="dark"] .device-option.checked {
  background: var(--theme-soft); border-color: var(--theme);
}
[data-theme="dark"] .device-type { background: var(--panel-4); color: var(--muted); }
[data-theme="dark"] .attachment-del { background: var(--panel-4); color: var(--muted); }
[data-theme="dark"] .attachment-del:hover { background: var(--line-strong); color: var(--danger); }
[data-theme="dark"] .file-progress .upload-retry,
[data-theme="dark"] .msg-row.failed .file-progress .upload-label { color: var(--danger); }
[data-theme="dark"] .msg-row.failed .file-progress .upload-fill { background: var(--danger); }
[data-theme="dark"] .detail-content,
[data-theme="dark"] .history-meta { background: var(--panel-3); }
[data-theme="dark"] .history-card:hover { background: var(--panel-3); }
[data-theme="dark"] .toast { background: rgba(40, 50, 65, .96); }
[data-theme="dark"] ::-webkit-scrollbar { width: 10px; height: 10px; }
[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--panel); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #46566e; }

/* ---------- 键盘焦点与触控补充 ---------- */

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(26, 115, 232, .42);
  outline-offset: 2px;
}
[data-theme="dark"] button:focus-visible,
[data-theme="dark"] a:focus-visible,
[data-theme="dark"] input:focus-visible,
[data-theme="dark"] textarea:focus-visible,
[data-theme="dark"] select:focus-visible,
[data-theme="dark"] [tabindex]:focus-visible {
  outline-color: rgba(110, 168, 255, .62);
}
.drawer-tab { min-height: 44px; }
.ticket-detail-tab { min-height: 40px; }
.quick-chip { min-height: 36px; }

/* ---------- 系统公告、对话搜索与回到最新 ---------- */

.system-notice {
  display: flex; align-items: center; gap: 10px; flex: none;
  padding: 10px 14px; border-bottom: 1px solid #fde68a;
  background: linear-gradient(90deg, #fffbeb, #fff7ed);
  color: #92400e; font-size: 13px;
}
.system-notice-icon { flex: none; font-size: 16px; line-height: 1; }
.system-notice-text { flex: 1; min-width: 0; line-height: 1.55; }
.system-notice .icon-close {
  flex: none; width: 32px; height: 32px; padding: 0; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #a16207; font-size: 18px;
}
.system-notice .icon-close:hover { background: rgba(161, 98, 7, .1); }

.chat-search {
  display: flex; align-items: center; gap: 8px; flex: none;
  padding: 8px 14px; border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.chat-search input {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel); color: var(--text); font: inherit; font-size: 13px;
  padding: 8px 11px; outline: none;
}
.chat-search input:focus { border-color: var(--theme); }
.chat-search-count {
  flex: none; min-width: 44px; text-align: center;
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.chat-search .tool-btn { min-height: 34px; }
mark.chat-hit { background: #fde68a; color: inherit; border-radius: 2px; padding: 0 1px; }
mark.chat-hit.active { background: #f59e0b; color: #fff; }

.jump-latest {
  align-self: center; flex: none; z-index: 6;
  margin: -48px 0 12px; min-height: 36px; padding: 7px 15px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); color: var(--theme);
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  box-shadow: 0 6px 18px var(--shadow-color);
}
.jump-latest:hover { border-color: var(--theme); background: var(--theme-soft); }

/* ---------- 日期分隔、未读分隔与加载更早消息 ---------- */

.date-separator,
.unread-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0 12px; font-size: 11.5px; color: var(--muted);
  white-space: nowrap;
}
.date-separator::before,
.date-separator::after,
.unread-divider::before,
.unread-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}
.unread-divider { color: var(--theme); font-weight: 600; }
.unread-divider::before,
.unread-divider::after { background: var(--theme-soft); }

.load-older-wrap { text-align: center; padding: 4px 0 12px; }
.load-older-btn { min-height: 34px; }

/* ---------- 消息骨架屏 ---------- */

.chat-skeleton { padding: 4px 0; }
.skeleton-row { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 14px; }
.skeleton-row.mine { flex-direction: row-reverse; }
.skeleton-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: linear-gradient(100deg, var(--panel-4) 25%, var(--panel-3) 45%, var(--panel-4) 65%);
  background-size: 220% 100%; animation: chat-skeleton-shimmer 1.35s ease-in-out infinite;
}
.skeleton-lines { display: flex; flex-direction: column; gap: 6px; width: min(62%, 420px); }
.skeleton-row.mine .skeleton-lines { align-items: flex-end; }
.skeleton-line {
  height: 12px; border-radius: 6px;
  background: linear-gradient(100deg, var(--panel-4) 25%, var(--panel-3) 45%, var(--panel-4) 65%);
  background-size: 220% 100%; animation: chat-skeleton-shimmer 1.35s ease-in-out infinite;
}
.skeleton-line.w40 { width: 40%; }
.skeleton-line.w50 { width: 50%; }
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w70 { width: 70%; }
.skeleton-line.w75 { width: 75%; }
.skeleton-line.w80 { width: 80%; }
.skeleton-line.w85 { width: 85%; }
.skeleton-line.w90 { width: 90%; }
@keyframes chat-skeleton-shimmer {
  0% { background-position: 120% 0; }
  100% { background-position: -20% 0; }
}

/* ---------- 工单动态字段 ---------- */

.detail-extra {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 14px; margin-bottom: 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel-3);
}
.detail-extra-row { display: flex; gap: 10px; font-size: 12.5px; line-height: 1.6; }
.detail-extra-label { flex: none; min-width: 84px; color: var(--muted); }
.detail-extra-value { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; }

/* ---------- 发送中、文件预览与远程输入状态 ---------- */

.composer.sending textarea { opacity: .72; }
.composer.sending .send-btn { cursor: progress; }
.file-preview-btn {
  flex: none; border: 1px solid var(--line); background: var(--panel);
  color: var(--theme); font: inherit; font-size: 12px; padding: 5px 9px;
  border-radius: 8px; cursor: pointer; line-height: 1.3;
}
.file-preview-btn:hover { border-color: var(--theme); background: var(--theme-soft); }
.remote-typing { margin-left: 40px; font-style: italic; animation: remote-typing-fade 1.4s ease-in-out infinite; }
@keyframes remote-typing-fade { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

.lightbox-frame {
  width: min(1100px, 100%); height: 100%;
  border: 0; border-radius: 8px; background: #fff;
}
.lightbox-text {
  margin: 0; width: min(1100px, 100%); height: 100%; overflow: auto;
  padding: 16px 18px; border-radius: 8px; background: #0f172a; color: #e5edf8;
  font: 12.5px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap; word-break: break-word; text-align: left;
}

/* ---------- 触控目标与窄屏补充 ---------- */

@media (pointer: coarse) {
  .tool-btn,
  .action-btn,
  .primary-btn.sm,
  .chat-search .tool-btn,
  .system-notice .icon-close,
  .jump-latest,
  .file-preview-btn { min-height: 40px; }
}
@media (max-width: 720px) {
  .system-notice { padding: 9px 12px; font-size: 12.5px; }
  .chat-search { padding: 7px 12px; gap: 6px; }
  .chat-search-count { min-width: 38px; font-size: 11.5px; }
  .jump-latest { margin: -44px 0 10px; min-height: 34px; padding: 6px 13px; font-size: 12px; }
  .skeleton-lines { width: min(72%, 320px); }
  .lightbox-text { padding: 12px 13px; font-size: 11.5px; }
}

/* ---------- 夜间模式补充 ---------- */

[data-theme="dark"] .system-notice {
  background: linear-gradient(90deg, #2a2415, #241f13);
  border-bottom-color: #5c4a1a; color: #fbbf24;
}
[data-theme="dark"] .system-notice .icon-close { color: #fbbf24; }
[data-theme="dark"] .system-notice .icon-close:hover { background: rgba(251, 191, 36, .12); }
[data-theme="dark"] .chat-search { background: var(--panel-2); }
[data-theme="dark"] .chat-search input { background: var(--panel-3); color: var(--text); }
[data-theme="dark"] mark.chat-hit { background: rgba(251, 191, 36, .32); color: var(--text); }
[data-theme="dark"] mark.chat-hit.active { background: #f59e0b; color: #111; }
[data-theme="dark"] .jump-latest { background: var(--panel); color: var(--theme); border-color: var(--line); }
[data-theme="dark"] .jump-latest:hover { background: var(--theme-soft); border-color: var(--theme); }
[data-theme="dark"] .detail-extra { background: var(--panel-3); }
[data-theme="dark"] .file-preview-btn { background: var(--panel-3); }
[data-theme="dark"] .file-preview-btn:hover { background: var(--theme-soft); }
[data-theme="dark"] .skeleton-avatar,
[data-theme="dark"] .skeleton-line {
  background-image: linear-gradient(100deg, var(--panel-4) 25%, #202b3d 45%, var(--panel-4) 65%);
}
[data-theme="dark"] .lightbox-text { background: #0a0f16; color: #dbe6f5; }

/* ---------- 列表搜索、加载更多与工单详情容器 ---------- */

.list-search { position: relative; display: flex; align-items: center; margin-bottom: 10px; }
.list-search input {
  flex: 1; min-width: 0; padding: 9px 36px 9px 11px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel-2); color: var(--text); font: inherit; font-size: 13px;
}
.list-search input:focus { border-color: var(--theme); outline: none; }
.list-search .icon-close {
  position: absolute; right: 3px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; padding: 0; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; color: var(--muted);
}
.list-search .icon-close:hover { background: var(--panel-4); color: var(--text); }
.load-more-btn { display: block; width: 100%; margin: 10px 0 4px; min-height: 38px; }
.reply-list { display: flex; flex-direction: column; gap: 2px; }
.timeline { display: flex; flex-direction: column; }
[data-theme="dark"] .list-search input { background: var(--panel-2); color: var(--text); }
[data-theme="dark"] .list-search .icon-close:hover { background: var(--panel-4); }
