/* Shell layout — three-pane IM workbench
   .app-shell → nav-rail (72px) | conv-col (300px, optional) | main (flex)
*/

.app-shell {
  display: flex;
  height: 100vh;
  width: 100%;
  min-width: 1260px;
  background: var(--bg-page);
  color: var(--text-body);
  overflow: hidden;
}

/* === NAV RAIL (72px) === */
.nav-rail {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, #F8FAFC 0%, #EFF6FF 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0 12px;
  gap: 4px;
}
.nav-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #60A5FA, var(--primary));
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
  cursor: pointer;
  user-select: none;
}
.nav-search {
  width: 56px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-soft, #f4f5f8);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 11px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s, color .15s;
}
.nav-search::before { content: '🔍'; font-size: 12px; line-height: 1; }
.nav-search:hover { border-color: var(--primary); color: var(--primary); background: #fff; box-shadow: 0 1px 7px rgba(66, 88, 230, 0.15); }
.nav-item {
  width: 52px;
  padding: 8px 4px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 10px;
  cursor: pointer;
  text-align: center;
  line-height: 1.2;
  background: transparent;
  border: none;
  transition: background 120ms, color 120ms;
}
.nav-item svg { width: 20px; height: 20px; opacity: 0.75; }
.nav-item:hover { color: var(--primary); }
.nav-item:hover svg { opacity: 1; }
.nav-item.is-active {
  background: #fff;
  color: var(--primary);
  box-shadow: var(--shadow-card);
}
.nav-item.is-active svg { opacity: 1; stroke: var(--primary); }
.nav-item.is-placeholder { opacity: 0.55; }
.nav-item.is-placeholder:hover { opacity: 0.85; }
.nav-divider {
  width: 36px;
  height: 1px;
  background: var(--border);
  margin: 6px 0;
  flex-shrink: 0;
}
.nav-spacer { flex: 1; }
/* Scrollable middle band — keeps avatar/search pinned at top and
   notifications/更多 pinned at bottom on short viewports. The 4px-wide
   scrollbar only appears when items overflow. */
.nav-items-scroll {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: scrollbar-color 160ms;
}
.nav-items-scroll:hover { scrollbar-color: var(--border) transparent; }
.nav-items-scroll::-webkit-scrollbar { width: 4px; }
.nav-items-scroll::-webkit-scrollbar-track { background: transparent; }
.nav-items-scroll::-webkit-scrollbar-thumb { background: transparent; border-radius: 4px; transition: background 160ms; }
.nav-items-scroll:hover::-webkit-scrollbar-thumb { background: var(--border); }
.nav-items-scroll:hover::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
.nav-badge { position: relative; }
.nav-badge-dot {
  position: absolute;
  top: -2px;
  right: 6px;
  background: #EF4444;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 14px;
  height: 14px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 0 4px;
}

/* === CONVERSATION COLUMN (300px, optional) === */
.conv-col-frame {
  width: var(--list-w);
  flex-shrink: 0;
  position: relative;
  display: flex;
  min-height: 0;
}
.conv-col-resizer {
  position: absolute;
  right: -3px; top: 0; bottom: 0;
  width: 7px;
  cursor: col-resize;
  z-index: 20;
}
.conv-col-resizer:hover, .conv-col-resizer.is-dragging {
  background: linear-gradient(90deg, transparent 2px, var(--primary, #2563eb) 2px, var(--primary, #2563eb) 5px, transparent 5px);
}
.conv-col {
  width: 100%;
  flex: 1;
  min-width: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.conv-col[hidden],
.conv-col.is-hidden { display: none; }

.conv-head {
  padding: 14px 14px 12px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-strong);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.conv-head-actions { display: flex; align-items: center; gap: 4px; }
.conv-head-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
}
.conv-head-btn:hover { background: var(--primary-soft); color: var(--primary); }
.conv-list { flex: 1; overflow-y: auto; }
.conv-row {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  transition: background 80ms;
}
.conv-row:hover { background: var(--bg-subtle); }
.conv-row.is-active {
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
  padding-left: 11px;
}
.conv-av {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
  background: #DBEAFE;
  color: var(--primary);
  font-weight: 800;
  font-size: 13px;
  display: grid;
  place-items: center;
  text-transform: uppercase;
}
.conv-av-bot { background: linear-gradient(135deg, #93C5FD, var(--primary)); color: #fff; }
.conv-av-system { background: var(--bg-subtle); color: var(--text-muted); }
.conv-meta { flex: 1; min-width: 0; }
.conv-title {
  font-weight: 700;
  color: var(--text-strong);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.conv-title-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 0 1 auto;
  min-width: 0;
}
.conv-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  flex-shrink: 0;
}
.conv-tag-official { background: var(--primary-soft); color: var(--primary); border: 1px solid #BFDBFE; }
.conv-tag-bot { background: #F0F9FF; color: #0369A1; border: 1px solid #BAE6FD; }
.conv-tag-task { background: #FEF3C7; color: #B45309; border: 1px solid #FDE68A; }
.conv-tag-system { background: var(--bg-subtle); color: var(--text-muted); border: 1px solid var(--border); }
.conv-tag-group { background: #ECFDF5; color: #047857; border: 1px solid #A7F3D0; }
.conv-tag-ai { background: var(--primary-soft, #EFF6FF); color: var(--primary); border: 1px solid #BFDBFE; }

/* v0.12 — pinned AI assistant single-chats above the human conversation list */
.conv-pinned { border-bottom: 6px solid var(--bg-subtle); }
.conv-pinned-label {
  padding: 10px 14px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-faint, var(--text-muted));
}
.conv-av--agent { color: #fff; background: var(--primary); }

/* 个股评级标签（研究对象） */
.conv-rating, .folder-rating { font-size: 10px; padding: 1px 6px; border-radius: 4px; font-weight: 600; flex-shrink: 0; white-space: nowrap; }
.rating-major  { background: #FEF2F2; color: #DC2626; border: 1px solid #FECACA; }
.rating-strong { background: #FFF7ED; color: #EA580C; border: 1px solid #FED7AA; }
.rating-watch  { background: #F1F5F9; color: #475569; border: 1px solid #E2E8F0; }
.conv-snippet {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}
.conv-date { color: #94A3B8; font-size: 11px; }
.conv-unread {
  background: #EF4444;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 0 5px;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.25);
}
.conv-row-del {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms, background 120ms, color 120ms;
}
.conv-row:hover .conv-row-del { opacity: 1; }
.conv-row-del:hover { background: #FEE2E2; color: #DC2626; }

/* === MAIN AREA === */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-panel);
  position: relative;
}
.main-top {
  height: var(--maintop-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  background: linear-gradient(180deg, #fff, #F8FAFC);
  flex-shrink: 0;
}
.main-top h1,
.main-top-title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: var(--text-strong);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.main-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.tool-icn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 9px;
  border: none;
  background: transparent;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
}
.tool-icn:hover { background: var(--primary-soft); color: var(--primary); }
.tool-icn svg { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; }
.tool-icn .tool-num { font-size: 12px; font-weight: 800; color: var(--text-strong); letter-spacing: -0.02em; }
.tool-icn:hover .tool-num { color: var(--primary); }

.main-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

/* Legacy alias — older screens still pass children to AppShell and expect
   a generic content container. Keep `.app-main` matching `.main-body`. */
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg-panel); overflow: hidden; }

/* === SCREEN HEADER (used inline by some screens — kept) === */
.screen-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--pad-3) var(--pad-4);
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  gap: var(--pad-3);
}
.screen-header-left { display: flex; align-items: center; gap: var(--pad-3); flex: 1; min-width: 0; }
.screen-header-right { display: flex; align-items: center; gap: var(--pad-2); }
.screen-title {
  font-size: var(--t-xl);
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.01em;
}
.screen-subtitle {
  font-size: var(--t-sm);
  color: var(--text-muted);
}
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--t-sm);
  color: var(--text-muted);
}
.breadcrumbs strong { color: var(--text-strong); font-weight: 600; }

/* === TABS (chip-style, matching prototype's main-top tab chips) === */
.tab-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  padding: 10px var(--pad-4);
  flex-wrap: wrap;
}
.tab-item {
  height: 28px;
  padding: 0 12px;
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.tab-item:hover { color: var(--primary); border-color: #BFDBFE; }
.tab-item.is-active {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: #BFDBFE;
  font-weight: 600;
}
.tab-count {
  font-family: var(--font-data);
  font-size: 10px;
  background: var(--bg-panel);
  color: var(--text-muted);
  padding: 1px 5px;
  border-radius: 8px;
}

/* === DATA TABLES === */
.dtable {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-md);
}
.dtable th {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  font-weight: 600;
  padding: 8px var(--pad-3);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}
.dtable th.num { text-align: right; }
.dtable td {
  padding: 8px var(--pad-3);
  border-bottom: 1px solid var(--border-soft);
  height: var(--row-h);
  color: var(--text-body);
}
.dtable td.num { text-align: right; font-family: var(--font-data); }
.dtable tbody tr:hover { background: var(--bg-subtle); }
.dtable tbody tr.is-selected { background: var(--primary-soft); }

/* Generic flex helpers */
.row { display: flex; align-items: center; gap: var(--pad-2); }
.col { display: flex; flex-direction: column; }
.spacer { flex: 1; }

/* Empty state */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--pad-5);
  color: var(--text-muted);
  text-align: center;
  gap: var(--pad-2);
}
.empty-title { font-size: var(--t-lg); color: var(--text-body); font-weight: 600; }

/* Side drawer (right slide-in for member/bot panels) */
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 58, 95, 0.14);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }
.side-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(380px, 44vw);
  background: #fff;
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px rgba(15, 23, 42, 0.1);
  z-index: 40;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.side-drawer.is-open { transform: translateX(0); }
.side-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.side-drawer-head h2 { margin: 0; font-size: 15px; font-weight: 800; color: var(--text-strong); }
.drawer-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 20px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.drawer-close:hover { background: var(--border); color: var(--text-strong); }
.side-drawer-body { flex: 1; overflow-y: auto; min-height: 0; }

/* ============================================================
   研究 conv-col 美化 (v0.12.x) — 文件夹列表
   ============================================================ */
/* 维度筛选 tabs：分段药丸式 */
.conv-dim-tabs {
  display: flex; gap: 6px; padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.conv-dim-btn {
  flex: 1; height: 28px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-subtle);
  color: var(--text-muted); font-size: 12px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.conv-dim-btn:hover { color: var(--text-strong); border-color: var(--primary-soft); }
.conv-dim-btn.is-active {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 2px 6px rgba(37,99,235,0.22);
}
.conv-dim-count {
  font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; display: inline-grid; place-items: center;
  background: rgba(0,0,0,0.06); color: inherit;
}
.conv-dim-btn.is-active .conv-dim-count { background: rgba(255,255,255,0.25); }

/* 返回研究首页 */
.conv-home-row {
  width: 100%; text-align: left; border: none; background: transparent;
  padding: 10px 14px; cursor: pointer;
  font-size: 12px; font-weight: 600; color: var(--primary);
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border-soft);
  transition: background 100ms;
}
.conv-home-row:hover { background: var(--primary-soft); }
.conv-home-ico {
  width: 20px; height: 20px; border-radius: 6px; flex-shrink: 0;
  display: grid; place-items: center; background: var(--primary-soft); color: var(--primary);
  font-weight: 800;
}

/* 文件夹头像按 kind 着色，列表一眼可分类 */
.conv-av-folder { border-radius: 11px; font-weight: 800; }
.conv-av-industry { background: linear-gradient(135deg, #5EEAD4, #0D9488); color: #fff; }
.conv-av-stock    { background: linear-gradient(135deg, #FCD34D, #D97706); color: #fff; }
.conv-av-theme    { background: linear-gradient(135deg, #C4B5FD, #7C3AED); color: #fff; }
.conv-av-research { background: linear-gradient(135deg, #93C5FD, #2563EB); color: #fff; }
.conv-av-other    { background: linear-gradient(135deg, #E2E8F0, #94A3B8); color: #fff; }

/* 研究文件夹行：更舒展的间距 + 更清晰的资料计数 */
.conv-col[aria-label="研究"] .conv-row { padding-top: 11px; padding-bottom: 11px; }
.conv-col[aria-label="研究"] .conv-snippet { margin-top: 3px; font-variant-numeric: tabular-nums; }
