:root {
  --navy: #1a2332;
  --navy-dark: #121925;
  --navy-hover: rgba(255,255,255,0.06);
  --accent: #0d9488;
  --gold: #c9a227;
  --bg: #f0f2f5;
  --panel: #ffffff;
  --border: #e2e8f0;
  --text: #1f2937;
  --muted: #64748b;
  --selected: #f5ebe0;
  --out-bubble: #95ec69;
  --in-bubble: #ffffff;
  --wechat: #07c160;
  --sidebar-w: 64px;
  --sidebar-w-collapsed: 64px;
  --rail-bg: #f0f0f0;
  --rail-icon: #191919;
  --rail-icon-muted: #7f7f7f;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--text); background: var(--bg); }

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) var(--inbox-w, 320px) 1fr var(--profile-w, 300px);
  grid-template-rows: 48px 1fr;
  grid-template-areas:
    "sidebar top top top"
    "sidebar inbox chat profile";
  height: 100vh;
  transition: grid-template-columns 0.2s ease;
}
/* Broadcast full-page view (also in broadcast-panel.css; kept here so layout never depends on that file alone) */
.app.view-broadcast {
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-areas:
    "sidebar top"
    "sidebar broadcast";
}
.app.view-broadcast .inbox-panel,
.app.view-broadcast .chat-panel,
.app.view-broadcast .profile-panel {
  display: none !important;
}
.app.resizing {
  transition: none;
  user-select: none;
  cursor: col-resize;
}
/* WeChat-style icon rail (方案 A) */
.sidebar {
  grid-area: sidebar;
  width: var(--sidebar-w);
  background: var(--rail-bg);
  color: var(--rail-icon);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0 12px;
  border-right: 1px solid #e5e5e5;
  overflow: hidden;
}
.rail-avatar {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  background: #07c160;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 18px;
  flex-shrink: 0;
  overflow: hidden;
  object-fit: cover;
  user-select: none;
}
.rail-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
}
.nav-item.rail-item {
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
  border-radius: 8px;
  color: #5b5b5b;
  text-decoration: none;
  position: relative;
  display: grid;
  place-items: center;
  transition: background 0.12s ease, color 0.12s ease;
}
/* Author display:grid beats UA [hidden]; keep permission-gated nav truly gone. */
.nav-item.rail-item[hidden] {
  display: none !important;
}
#nav-inbox:not(.active) {
  color: #5b5b5b;
}
.nav-item.rail-item:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--rail-icon);
}
.nav-item.rail-item.active {
  background: transparent;
  color: var(--wechat);
  font-weight: 600;
  box-shadow: none;
}
.nav-item.rail-item.is-placeholder {
  opacity: 0.38;
  pointer-events: none;
  cursor: not-allowed;
}
.rail-ico {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
}
.rail-ico .ico-filled { display: none; }
.nav-item.rail-item.active .rail-ico .ico-outline { display: none; }
.nav-item.rail-item.active .rail-ico .ico-filled { display: block; }

.badge {
  position: absolute;
  top: 2px;
  right: 0;
  display: inline-block;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #fa5151;
  color: #fff;
  font-size: 10px;
  text-align: center;
  line-height: 16px;
  font-weight: 700;
  box-sizing: border-box;
}
.nav-item.rail-item.active .badge {
  background: #fa5151;
  color: #fff;
}
.badge[hidden] { display: none !important; }

.sidebar-footer {
  margin-top: auto;
  width: 100%;
  padding: 8px 0 0;
  border-top: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* Legacy group hooks (hidden in rail layout) */
.sidebar .nav-group,
.sidebar .nav-group-toggle,
.sidebar .nav-sub,
.sidebar .nav-caret,
.sidebar .brand,
.sidebar .sidebar-collapse,
.sidebar .sidebar-meta { display: none !important; }

.topbar { grid-area: top; background: var(--panel); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 20px; gap: 16px; }
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-title { display: none; margin: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--muted); }
.topbar-right .lang-toggle { padding: 4px 10px; font-size: 12px; line-height: 1.2; }
.online { color: #16a34a; }
.online::before { content: "● "; }
.online.offline { color: #dc2626; }

.inbox-panel, .chat-panel, .profile-panel { background: var(--panel); border-right: 1px solid var(--border); overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.profile-panel { border-right: none; padding: 16px; gap: 16px; overflow-y: auto; }
.inbox-panel { grid-area: inbox; }
.chat-panel { grid-area: chat; background: #fafbfc; }
.profile-panel { grid-area: profile; }

/* Draggable column resizers: list|chat and chat|profile boundaries */
.col-resizer {
  justify-self: start;
  width: 11px;
  margin-left: -6px;
  position: relative;
  z-index: 30;
  cursor: col-resize;
  background: transparent;
  touch-action: none;
}
#resizer-inbox { grid-area: chat; }
#resizer-profile { grid-area: profile; }
.col-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 5px;
  width: 2px;
  background: transparent;
  transition: background 0.12s ease;
}
.col-resizer:hover::after,
.col-resizer.dragging::after { background: var(--accent); }
/* Only the inbox view has resizable columns */
.app[class*="view-"] .col-resizer { display: none; }

.panel-header, .chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.panel-header-actions { justify-content: flex-end; }
.panel-header h1, .chat-header h2 { margin: 0; font-size: 18px; }
.chat-identity { margin: 4px 0 0; font-size: 12px; color: var(--muted, #667085); display: flex; flex-wrap: wrap; gap: 8px; }
.case-drivers { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.case-drivers[hidden] { display: none; }
.case-chip { border: 1px solid #d0d5dd; background: #f8fafc; border-radius: 999px; padding: 2px 8px; font-size: 12px; cursor: pointer; }
.chat-header-main { display: flex; align-items: flex-start; gap: 12px; }
.chat-title-block { min-width: 0; flex: 1; }
.chat-title-row { display: flex; align-items: center; gap: 10px; }
.chat-detail { margin-top: 8px; display: grid; gap: 8px; }
.chat-detail[hidden] { display: none; }
.chat-detail-row { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 8px; align-items: center; }
.chat-detail-label { font-size: 12px; color: var(--muted, #667085); }
.chat-detail .chat-identity { margin: 0; }
.chat-detail .case-drivers { margin-top: 0; }
.chat-detail .collab-line { margin: 0; max-width: none; }
.section-fold { display: flex; align-items: center; gap: 6px; width: 100%; border: 0; background: none; padding: 0; cursor: pointer; text-align: left; }
.section-fold h3 { margin: 0; font-size: 14px; }
#notes-panel { margin-top: 10px; }
#notes-panel[hidden] { display: none; }
.fold-link { border: 0; background: none; padding: 0; color: #0f766e; font-size: 13px; cursor: pointer; }
.fold-link.open { font-weight: 600; }
.fold-link[hidden] { display: none; }
.summary-fold { display: flex; align-items: center; gap: 6px; width: 100%; margin-top: 8px; padding: 0; border: 0; background: none; text-align: left; color: var(--muted, #667085); font-size: 12px; cursor: pointer; }
#summary-list { margin-top: 8px; }
#summary-list[hidden] { display: none; }
.guest-tag.ai { background: #eef2ff; border-color: #c7d2fe; }
.tier-mark.tier-gold { color: #b45309; }
.tier-mark.tier-silver { color: #64748b; }
.tier-mark.tier-diamond { color: #6d28d9; }
.tier-mark.tier-regular { color: #0f766e; }
.msg-video { max-width: 240px; max-height: 180px; border-radius: 8px; background: #111; }
.msg-location { color: inherit; }
.note-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; max-height: 220px; overflow: auto; }
.note-item { border: 1px solid var(--border, #e5e7eb); border-radius: 8px; padding: 8px; }
.note-meta { font-size: 12px; color: var(--muted, #667085); margin-bottom: 4px; }
.note-body { white-space: pre-wrap; font-size: 13px; line-height: 1.5; }
.note-actions { display: flex; gap: 8px; margin-top: 8px; }
#note-input, #note-visibility, .summary-input { width: 100%; box-sizing: border-box; font-size: 13px; font-family: inherit; }
#note-visibility { width: auto; }
.chat-header-main { display: flex; align-items: flex-start; gap: 12px; }
.chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: #e2e8f0;
  flex-shrink: 0;
}
.chat-avatar.placeholder {
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--navy);
  background: #dbeafe;
}
.chat-avatar.placeholder.ch-whatsapp,
.conv-avatar.placeholder.ch-whatsapp,
.msg-avatar.placeholder.ch-whatsapp { background: #25d366; color: #fff; }
.chat-avatar.placeholder.ch-telegram,
.conv-avatar.placeholder.ch-telegram,
.msg-avatar.placeholder.ch-telegram { background: #229ed9; color: #fff; }
.chat-avatar.placeholder.ch-messenger,
.conv-avatar.placeholder.ch-messenger,
.msg-avatar.placeholder.ch-messenger { background: #0084ff; color: #fff; }
.channels { margin: 6px 0 0; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.tag.wechat { background: #dcfce7; color: #15803d; }
.tag.telegram { background: #dbeafe; color: #1d4ed8; }
.tag.whatsapp { background: #dcfce7; color: #15803d; }
.tag.messenger { background: #dbeafe; color: #2563eb; }
.tag.webchat { background: #ccfbf1; color: #0f766e; }
.chat-avatar.placeholder.ch-webchat,
.conv-avatar.placeholder.ch-webchat,
.msg-avatar.placeholder.ch-webchat { background: #0d9488; color: #fff; }
.voice-play {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.voice-play:hover { text-decoration: underline; }
.file-download {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-align: left;
}
.file-download:hover { text-decoration: underline; }
.msg-image-link {
  display: inline-block;
  max-width: 100%;
  text-decoration: none;
  color: inherit;
  line-height: 0;
}
.msg-image {
  display: block;
  max-width: 240px;
  max-height: 240px;
  border-radius: 8px;
  cursor: zoom-in;
  background: #f1f5f9;
  -webkit-user-drag: auto;
  user-select: auto;
}
.oct-ctx-menu {
  position: fixed;
  z-index: 9999;
  min-width: 128px;
  padding: 4px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}
.oct-ctx-item {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: #0f172a;
  cursor: pointer;
}
.oct-ctx-item:hover {
  background: #f1f5f9;
}

.header-actions { display: flex; gap: 8px; }
.btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
}
.btn.ghost { background: transparent; }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.secondary { background: #eef2ff; border-color: #c7d2fe; color: #3730a3; }
.ai-card .btn.secondary { width: auto; margin-top: 0; }
.ai-auto-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.ai-auto-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.ai-auto-label input { width: 16px; height: 16px; accent-color: var(--navy); cursor: pointer; }
.ai-auto-status {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
}
.ai-auto-status.on {
  background: #ecfdf5;
  color: #047857;
}
.ai-auto-hint { margin: 0 0 10px; font-size: 12px; line-height: 1.45; }
.member-pending {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  font-size: 13px;
}
.member-pending-text { margin: 0 0 8px; line-height: 1.45; color: #9a3412; }
.member-pending-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.agent-pending-preview {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #fed7aa;
  color: #7c2d12;
  white-space: pre-wrap;
  word-break: break-word;
  font: inherit;
  font-size: 12px;
  line-height: 1.45;
  max-height: 160px;
  overflow: auto;
}
.member-info { margin-top: 4px; }
.member-info h4 { margin: 0 0 8px; font-size: 13px; }
.profile-ext-list { display: flex; flex-direction: column; gap: 14px; }
.profile-ext-block {
  margin: 0;
  padding: 10px 0 0;
  border-top: 1px dashed #e2e8f0;
}
.profile-ext-block:first-child { padding-top: 0; border-top: none; }
.profile-ext-title {
  display: block;
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy, #0f2744);
}
/* Each Skill block owns its own dl grid — never nest dl inside dl */
.profile-ext-dl {
  margin: 0;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 8px 10px;
  font-size: 13px;
}
.profile-ext-dl dt { color: var(--muted); min-width: 0; }
.profile-ext-dl dd {
  margin: 0;
  font-weight: 500;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.ai-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.ai-actions .btn { flex: 1; }
.ai-note { margin: 8px 0 0; font-size: 12px; }
.ai-latest {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.45;
  padding-bottom: 8px;
  border-bottom: 1px dashed #e2e8f0;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.search-box { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.search-box input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}

.tabs { display: flex; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.tab {
  border: none;
  background: transparent;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
}
.tab.active { background: var(--selected); color: var(--text); font-weight: 600; }

.conversation-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.conversation-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.conversation-item:hover { background: #f8fafc; }
.conversation-item.active { background: var(--selected); }
.conversation-item.is-closed { opacity: 0.78; }
.conversation-item.is-closed .conv-name { color: #64748b; }
.tag.status-tag.st-open { background: #dcfce7; color: #166534; }
.tag.status-tag.st-waiting { background: #fef3c7; color: #92400e; }
.tag.status-tag.st-menu { background: #e0e7ff; color: #3730a3; }
.tag.status-tag.st-closed { background: #e2e8f0; color: #475569; }
.tag.agent-tag.has-agent { background: #fce7f3; color: #9d174d; }
.tag.agent-tag.no-agent { background: #f1f5f9; color: #64748b; }
.conv-avatar-wrap {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}
.conv-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  background: #e2e8f0;
  display: block;
}
.conv-avatar.placeholder {
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  background: #dbeafe;
}
.conv-avatar-wrap .unread-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid #fff;
  box-sizing: content-box;
  margin: 0;
  pointer-events: none;
}
.conv-body { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.conv-name { font-weight: 600; font-size: 14px; }
.conv-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.conv-preview { font-size: 13px; color: var(--muted); margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: #ef4444; margin-left: auto; }

.messages { flex: 1; overflow-y: auto; padding: 16px 12px; display: flex; flex-direction: column; gap: 10px; }
.msg-system { text-align: center; color: var(--muted); font-size: 12px; margin: 4px 0; }
.msg-time-divider {
  align-self: center;
  text-align: center;
  font-size: 12px;
  color: #b2b2b2;
  line-height: 1.4;
  margin: 6px 0 2px;
  user-select: none;
}
.msg-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.msg-row.out { flex-direction: row-reverse; }
.msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  flex-shrink: 0;
  object-fit: cover;
  background: #e2e8f0;
}
.msg-avatar.placeholder {
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  background: #dbeafe;
}
.msg-avatar.placeholder.out {
  background: #95ec69;
  color: #14532d;
}
.bubble {
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.45;
  width: fit-content;
  max-width: min(70%, 420px);
  box-shadow: none;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-row.in .bubble { background: #ffffff; border: 1px solid #e5e7eb; }
.msg-row.out .bubble { background: #95ec69; border: 1px solid #86efac; }
.msg-time { display: none; }

.composer { border-top: 1px solid var(--border); background: var(--panel); padding: 12px 16px 16px; }
.composer-tools { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; align-items: center; }
.live-call-bar { display: flex; align-items: center; gap: 8px; margin: 0 16px 8px; padding: 8px 10px; background: #ecfdf5; border: 1px solid #99f6e4; border-radius: 10px; }
.live-call-bar[hidden] { display: none; }
.live-call-bar button { border: 0; border-radius: 8px; padding: 6px 12px; font-weight: 600; cursor: pointer; background: #0d9488; color: #fff; }
.live-call-bar button.danger { background: #b91c1c; }
.live-call-bar button.cam { background: #334155; }
.live-video-stage { position: relative; height: 280px; margin: 0 16px 8px; background: #111; border-radius: 12px; overflow: hidden; }
.live-video-stage[hidden] { display: none; }
.live-video-stage video { width: 100%; height: 100%; object-fit: cover; background: #111; }
.live-video-stage video.local, #live-video-local { position: absolute; right: 10px; bottom: 10px; width: 120px; height: 90px; border-radius: 8px; border: 1px solid rgba(255,255,255,.45); }
.guest-lang-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  line-height: 1.4;
  border: 1px solid #c7d2fe;
}
.guest-lang-wrap.empty { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; }
.guest-lang-wrap.detecting { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.guest-lang-prefix { white-space: nowrap; }
.guest-lang-select {
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  padding: 2px 4px;
  max-width: 120px;
  cursor: pointer;
  outline: none;
}
.guest-lang-select:disabled { cursor: default; opacity: 0.7; }
.view-lang-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 10px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  font-size: 12px;
  line-height: 1.4;
  border: 1px solid #a7f3d0;
}
.view-lang-prefix { white-space: nowrap; }
.msg-text-original { white-space: pre-wrap; word-break: break-word; }
.msg-text-trans {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(100, 116, 139, 0.35);
  font-size: 12.5px;
  line-height: 1.45;
  color: #475569;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-row.out .msg-text-trans { color: #334155; border-top-color: rgba(30, 58, 95, 0.25); }
.msg-text-trans.loading { opacity: 0.65; font-style: italic; }
.msg-text-trans .trans-label {
  display: block;
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 2px;
}
.msg-trans-slot { margin-top: 6px; }
.msg-translate-btn {
  border: none;
  background: transparent;
  color: #2563eb;
  font-size: 12px;
  line-height: 1.4;
  padding: 0;
  cursor: pointer;
}
.msg-translate-btn:hover { text-decoration: underline; }
.msg-row.out .msg-translate-btn { color: #1d4ed8; }
.tool { border: none; background: #f1f5f9; border-radius: 6px; padding: 6px 10px; font-size: 12px; cursor: pointer; }
.tool.recording { background: #fee2e2; color: #b91c1c; }
.tool:disabled { opacity: 0.5; cursor: not-allowed; }
.composer-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  width: 100%;
}
.composer-row textarea {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  resize: vertical;
  min-height: 64px;
  max-height: 180px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  line-height: 1.4;
}
.composer-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 0 0 auto;
}
.composer-actions .btn {
  white-space: nowrap;
  min-width: 72px;
  padding: 8px 12px;
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.card h3 { margin: 0 0 12px; font-size: 14px; }
.card dl { margin: 0; display: grid; grid-template-columns: 92px 1fr; gap: 8px 10px; font-size: 13px; }
.card dt { color: var(--muted); }
.card dd { margin: 0; font-weight: 500; }
.link { display: inline-block; margin-top: 12px; font-size: 13px; color: var(--navy); text-decoration: none; }

.ai-box { background: #f8fafc; border-radius: 10px; padding: 12px; font-size: 13px; line-height: 1.6; }
.ai-meta { margin-top: 10px; font-size: 12px; color: var(--muted); }
.confidence { float: right; color: #16a34a; font-weight: 600; }

.empty-state {
  flex: 1;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  padding: 40px;
  text-align: center;
}

.typing { margin: 4px 0 0; font-size: 12px; color: #16a34a; min-height: 18px; }
.conv-preview.is-typing { color: #16a34a; }
.collab-line {
  position: relative;
  margin: 4px 0 0;
  font-size: 12px;
  color: #64748b;
  line-height: 1.35;
  max-width: 520px;
}
.collab-line .collab-online { color: #16a34a; }
.collab-title-btn,
.collab-members-btn {
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.collab-title-btn {
  font-weight: 700;
  color: #0f172a;
  border-bottom: 1px dashed #94a3b8;
}
.collab-title-btn:hover { color: #2563eb; border-bottom-color: #2563eb; }
.collab-members-btn:hover { color: #2563eb; text-decoration: underline; }
.collab-title-input {
  font: inherit;
  font-weight: 700;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 2px 6px;
  min-width: 120px;
  max-width: 220px;
}
.collab-members-panel {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  width: 280px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  z-index: 35;
  padding: 10px 12px;
}
.collab-members-head { font-weight: 600; font-size: 13px; margin-bottom: 6px; color: #0f172a; }
.collab-members-list { list-style: none; margin: 0; padding: 0; }
.collab-members-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid #f1f5f9;
  font-size: 13px;
  color: #334155;
}
.collab-remove-btn { font-size: 12px; padding: 2px 8px; }
.bell-wrap { position: relative; display: inline-flex; align-items: center; }
.bell {
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  padding: 0 4px;
}
.invite-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 320px;
  max-height: 360px;
  overflow: auto;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  z-index: 40;
  padding: 10px 12px;
}
.invite-panel-head { font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.invite-panel-list { list-style: none; margin: 0; padding: 0; }
.invite-panel-list li {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0;
  border-top: 1px solid #f1f5f9;
  font-size: 13px;
}
.invite-panel-list .invite-actions { display: flex; gap: 8px; }
.invite-panel-empty { margin: 0; font-size: 12px; color: #94a3b8; }

@media (max-width: 1200px) {
  .app {
    grid-template-columns: var(--sidebar-w) var(--inbox-w, 280px) 1fr;
    grid-template-areas:
      "sidebar top top"
      "sidebar inbox chat";
  }
  .profile-panel, #resizer-profile { display: none; }
}
