/* ai_infra 终端同款视觉（WorkBuddy 配色体系），maintainer 知识工作台。
   复刻自 ai_infra frontend index.css 的 wb-* 设计系统 + Terminal.tsx 内联样式。 */

:root {
  --tv-primary: #6366F1;
  --tv-sidebar: #F8F9FC;
  --tv-hover: #EEF0F7;
  --tv-border: #E5E7EB;
  --tv-user-msg: #F0F1F5;
  --tv-bot-msg: #ffffff;
  --tv-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --tv-mono: 'SF Mono', 'Fira Code', 'Menlo', monospace;
}

/* ── 整体壳：两栏（224px 侧栏 + 主区） ───────────────────────────── */
#terminal-root { position: fixed; inset: 0; z-index: 50; background: #f5f5f5;
  font-family: var(--tv-font); font-size: 13px; color: #1f2937; }
.tv-shell { height: 100%; display: flex; overflow: hidden; }

.tv-side { width: 224px; background: var(--tv-sidebar);
  border-right: 1px solid var(--tv-border); display: flex; flex-direction: column;
  flex: 0 0 auto; }
.tv-side-pad { padding: 12px; }
.tv-btn-new { display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; height: 32px; border: none; border-radius: 6px; cursor: pointer;
  background: var(--tv-primary); color: #fff; font-size: 13px; font-family: var(--tv-font); }
.tv-btn-new:hover { background: #4f52e8; }

.tv-nav { padding: 4px 8px; }
.tv-nav-item { display: flex; align-items: center; gap: 10px; height: 34px;
  padding: 0 10px; border-radius: 6px; cursor: pointer; font-size: 13px;
  color: #374151; user-select: none; }
.tv-nav-item:hover { background: var(--tv-hover); }
.tv-nav-item.active { background: #E8EAFE; color: var(--tv-primary); font-weight: 600; }
.tv-nav-item svg { flex: 0 0 auto; }

.tv-side-label { padding: 8px 16px; margin-top: 4px; font-size: 12px;
  color: #6b7280; font-weight: 500; margin-bottom: 8px; }
.tv-side-list { flex: 1; overflow-y: auto; padding: 0 8px; }
.tv-side-list::-webkit-scrollbar { width: 6px; }
.tv-side-list::-webkit-scrollbar-thumb { background: #d9dce3; border-radius: 3px; }

.tv-task-item { display: flex; align-items: flex-start; gap: 8px;
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 12px;
  color: #6b7280; position: relative; }
.tv-task-item:hover { background: var(--tv-hover); }
.tv-task-item.active { background: rgba(99, 102, 241, 0.10); color: var(--tv-primary); }
.tv-task-item .tv-task-title { flex: 1; line-height: 1.4; overflow: hidden;
  text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; word-break: break-all; }
.tv-task-item .tv-task-ops { display: flex; align-items: center; gap: 4px;
  flex-shrink: 0; margin-top: 2px; }
.tv-task-item .tv-task-date { color: #cbd5e1; font-size: 10px; }
.tv-task-item:hover .tv-task-date { display: none; }
.tv-task-item .tv-task-act { display: none; align-items: center; gap: 4px; }
.tv-task-item:hover .tv-task-act, .tv-task-item.active .tv-task-act { display: inline-flex; }
.tv-task-item:hover .tv-task-date { display: none; }
.tv-task-edit { width: 100%; font-size: 12px; padding: 0 6px; height: 24px;
  border: 1px solid var(--tv-border); border-radius: 4px; outline: none;
  font-family: var(--tv-font); }

.tv-side-user { padding: 12px; border-top: 1px solid var(--tv-border); flex: 0 0 auto; }
.tv-side-user-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.tv-avatar { display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; color: #fff; font-size: 12px; flex: 0 0 auto; }
.tv-avatar.me { width: 20px; height: 20px; background: #ede9fe; color: #7c3aed; font-size: 10px; }
.tv-avatar.user { width: 28px; height: 28px; font-size: 13px;
  background: linear-gradient(135deg, #34d399 0%, #14b8a6 100%); }
.tv-side-user-name { font-size: 13px; color: #374151; flex: 1; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.tv-user-menu { position: absolute; bottom: 64px; left: 12px; width: 200px;
  background: #fff; border: 1px solid var(--tv-border); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.10); padding: 8px; z-index: 60; }
.tv-user-menu .tv-menu-item { display: flex; align-items: center; justify-content: center;
  gap: 6px; width: 100%; height: 30px; border: none; background: none;
  border-radius: 6px; cursor: pointer; font-size: 13px; font-family: var(--tv-font);
  color: #374151; }
.tv-user-menu .tv-menu-item:hover { background: var(--tv-hover); }
.tv-user-menu .tv-menu-item.danger { color: #dc2626; }
.tv-user-menu .tv-menu-org { font-size: 12px; color: #9ca3af; margin-bottom: 8px;
  padding: 0 6px; }

.tv-main { flex: 1; display: flex; flex-direction: column; background: #fff; min-width: 0; }

/* ── 首页欢迎视图 ─────────────────────────────────────────────── */
.tv-home { flex: 1; display: flex; flex-direction: column; }
.tv-home-top { height: 44px; display: flex; align-items: center;
  justify-content: flex-end; padding: 0 16px;
  border-bottom: 1px solid var(--tv-border); flex: 0 0 auto; }
.tv-ready-dot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #6b7280; }
.tv-ready-dot i { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; }
.tv-home-body { flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 0 32px; overflow-y: auto; }
.tv-hero-icon { width: 72px; height: 72px; margin-bottom: 24px; }
.tv-hero-title { font-size: 30px; font-weight: 700; color: #111827; margin: 0 0 4px; }
.tv-hero-sub { font-size: 22px; font-weight: 600; color: #1f2937; margin: 0 0 16px; }

/* 三模式分段开关 */
.wb-taskmode { position: relative; display: inline-flex; padding: 3px;
  border: 1px solid #e5e7eb; border-radius: 999px; background: #fff;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04); user-select: none; margin-bottom: 24px; }
.wb-taskmode-thumb { position: absolute; top: 3px; bottom: 3px; left: 3px;
  width: calc((100% - 6px) / 3); border-radius: 999px; background: #1f2937;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1); }
.wb-taskmode[data-mode='material'] .wb-taskmode-thumb { transform: translateX(100%); }
.wb-taskmode[data-mode='memory'] .wb-taskmode-thumb { transform: translateX(200%); }
.wb-taskmode-option { position: relative; z-index: 1; display: inline-flex;
  align-items: center; justify-content: center; gap: 7px; width: 138px;
  padding: 7px 0; border: none; background: transparent; cursor: pointer;
  border-radius: 999px; font-size: 13px; font-weight: 500; color: #6b7280;
  white-space: nowrap; transition: color 0.22s ease; font-family: var(--tv-font); }
.wb-taskmode-option:hover { color: #111827; }
.wb-taskmode-option.active { color: #fff; }

/* 场景提示词按钮 */
.wb-scene-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px 0; }
.wb-scene { display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border: 1px solid #e5e7eb; border-radius: 999px;
  background: #fff; cursor: pointer; font-size: 12px; color: #6b7280;
  white-space: nowrap; transition: color .18s ease, border-color .18s ease, background .18s ease;
  font-family: var(--tv-font); }
.wb-scene:hover { color: #111827; border-color: #d1d5db; }
.wb-scene.active { color: #4f46e5; border-color: #c7c3f8; background: #eef2ff; }

/* ── 任务输入框（作曲器 = 跟进框同款） ─────────────────────────── */
.tv-composer { width: 100%; border: 1px solid var(--tv-border); border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04); background: #fff; position: relative;
  text-align: left; }
.tv-composer.drag { border-color: var(--tv-primary); background: rgba(99, 102, 241, 0.05); }
.tv-composer textarea { width: 100%; border: none; outline: none; resize: none;
  padding: 12px; font-size: 13px; line-height: 1.6; font-family: var(--tv-font);
  color: #1f2937; background: transparent; display: block; max-height: 200px; }
.tv-composer textarea::placeholder { color: #9ca3af; }
.tv-att-row { padding: 8px 12px 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tv-att-chip { display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px; border-radius: 6px; font-size: 12px; background: #f3f4f6;
  border: 1px solid var(--tv-border); color: #374151; max-width: 100%; }
.tv-att-chip.error { background: #fef2f2; border-color: #fecaca; color: #dc2626; }
.tv-att-chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-att-chip .size { color: #9ca3af; flex-shrink: 0; }
.tv-att-chip .prog { color: var(--tv-primary); flex-shrink: 0; }
.tv-att-chip .rm { cursor: pointer; color: #9ca3af; font-size: 11px; flex-shrink: 0;
  background: none; border: none; padding: 0; }

.tv-composer-bar { display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-top: 1px solid var(--tv-border); gap: 8px; }
.tv-chips { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tv-chip-btn { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 6px; border: none; background: transparent; cursor: pointer;
  font-size: 12px; color: #6b7280; font-family: var(--tv-font); white-space: nowrap; }
.tv-chip-btn:hover { background: var(--tv-hover); color: #374151; }
.tv-chip-btn svg { flex: 0 0 auto; }
.tv-vsep { width: 1px; height: 14px; background: var(--tv-border); }
.tv-cfg-trigger { display: inline-flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 2px 6px; border-radius: 6px; }
.tv-cfg-trigger:hover { background: var(--tv-hover); }
.tv-send-btn { width: 32px; height: 32px; border-radius: 8px; border: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  background: var(--tv-primary); color: #fff; flex: 0 0 auto; }
.tv-send-btn:disabled { background: #e5e7eb; cursor: default; }
.tv-stop-btn { width: 32px; height: 32px; border-radius: 8px; border: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  background: #fee2e2; color: #dc2626; flex: 0 0 auto; }

/* 引用选择下拉（技能/文件/提示词） */
.tv-picker { position: absolute; bottom: calc(100% + 6px); left: 0; width: 300px;
  max-height: 360px; background: #fff; border: 1px solid var(--tv-border);
  border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.10); z-index: 40;
  display: flex; flex-direction: column; overflow: hidden; }
.tv-picker input { width: 100%; border: none; border-bottom: 1px solid var(--tv-border);
  outline: none; padding: 8px 10px; font-size: 13px; font-family: var(--tv-font); }
.tv-picker-list { flex: 1; overflow-y: auto; margin-top: 6px; min-height: 60px; }
.tv-picker-item { padding: 6px 8px; cursor: pointer; border-radius: 6px; font-size: 13px; }
.tv-picker-item:hover { background: var(--tv-hover); }
.tv-picker-item .t { font-weight: 500; display: flex; align-items: center; gap: 6px; }
.tv-picker-item .s { font-size: 12px; color: #9ca3af; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.tv-picker-empty { padding: 12px; color: #9ca3af; font-size: 12px; text-align: center; }
.tv-picker-note { border-top: 1px solid var(--tv-border); margin-top: 6px;
  padding: 6px 10px; font-size: 12px; color: #9ca3af; }

/* 执行模式下拉（原生 select 伪装 chip） */
.tv-execmode { position: relative; }
.tv-execmenu { position: absolute; bottom: calc(100% + 6px); left: 0; width: 220px;
  background: #fff; border: 1px solid var(--tv-border); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.10); z-index: 40; padding: 4px; }
.tv-execmenu .opt { padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.tv-execmenu .opt:hover { background: var(--tv-hover); }
.tv-execmenu .opt .n { font-weight: 500; }
.tv-execmenu .opt .d { font-size: 12px; color: #9ca3af; }

/* ── 聊天视图 ─────────────────────────────────────────────────── */
.tv-chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.tv-chat-head { height: 44px; display: flex; align-items: center; padding: 0 16px;
  border-bottom: 1px solid var(--tv-border); flex: 0 0 auto; gap: 8px; }
.tv-chat-title { font-size: 13px; font-weight: 500; color: #1f2937; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.tv-icon-btn { width: 26px; height: 26px; border: none; background: transparent;
  border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; color: #6b7280; }
.tv-icon-btn:hover { background: var(--tv-hover); color: #1f2937; }

.tv-chat-scroll { flex: 1; overflow-y: auto; padding: 24px; background: #fafafa; }
.tv-chat-scroll::-webkit-scrollbar { width: 6px; }
.tv-chat-scroll::-webkit-scrollbar-thumb { background: #d9dce3; border-radius: 3px; }
.tv-chat-inner { max-width: 820px; margin: 0 auto; }

.tv-turn { display: flex; justify-content: flex-start; margin-bottom: 18px;
  align-items: flex-start; gap: 8px; }
.tv-turn.user { justify-content: flex-end; }

.tv-user-bubble { max-width: 80%; background: var(--tv-user-msg);
  border-radius: 16px 16px 4px 16px; padding: 12px 16px; }
.tv-user-bubble .head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.tv-user-bubble .head .who { font-size: 12px; color: #6b7280; }
.tv-user-bubble .body { font-size: 13px; color: #1f2937; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word; }
.tv-turn-del { color: #9ca3af; cursor: pointer; margin-top: 14px; flex-shrink: 0;
  background: none; border: none; padding: 2px; display: none; }
.tv-turn.user:hover .tv-turn-del { display: inline-block; }

.tv-bot { max-width: 92%; }
.tv-bot-avatar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.tv-bot-avatar img { width: 28px; height: 28px; object-fit: contain; display: block; }
.tv-bot-avatar .name { font-size: 13px; font-weight: 500; color: #1f2937; }
.tv-live-tag { font-size: 12px; color: var(--tv-primary); border: 1px solid #c7d2fe;
  background: #eef2ff; border-radius: 4px; padding: 0 5px; line-height: 18px; }
.tv-bot-bubble { background: var(--tv-bot-msg); border: 1px solid var(--tv-border);
  border-radius: 16px 16px 16px 4px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  padding: 16px; }
.tv-bot-status { display: flex; align-items: center; gap: 6px; font-size: 12px;
  margin-bottom: 8px; color: var(--tv-primary); }
.tv-bot-status.done { color: #22c55e; }

.tv-token-bar { display: flex; align-items: center; gap: 10px; justify-content: center;
  margin-top: 6px; font-size: 12px; color: #9ca3af; }
.tv-token-bar.live { color: var(--tv-primary); animation: wb-token-pulse 1.6s ease-in-out infinite; }
@keyframes wb-token-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

.tv-input-area { padding: 12px 16px 16px; background: #fafafa; flex: 0 0 auto; }
.tv-input-area .inner { max-width: 820px; margin: 0 auto; }
.tv-input-note { text-align: center; margin-top: 6px; font-size: 12px; color: #9ca3af; }

/* ── 执行过程块（wb-* 复刻） ──────────────────────────────────── */
.wb-md { font-size: 13px; line-height: 1.7; color: #374151; word-break: break-word; }
.wb-md > *:first-child { margin-top: 0; }
.wb-md > *:last-child { margin-bottom: 0; }
.wb-md p { margin: 6px 0; }
.wb-md h1, .wb-md h2, .wb-md h3, .wb-md h4 { margin: 12px 0 6px; font-weight: 600;
  line-height: 1.4; color: #111827; font-size: 13px; }
.wb-md ul, .wb-md ol { margin: 6px 0; padding-left: 22px; }
.wb-md li { margin: 3px 0; }
.wb-md blockquote { margin: 8px 0; padding: 4px 12px; color: #6b7280;
  border-left: 3px solid #E5E7EB; background: #fafafa; }
.wb-md a { color: #6366F1; text-decoration: none; cursor: pointer; }
.wb-md a:hover { text-decoration: underline; }
.wb-md table { margin: 8px 0; border-collapse: collapse; width: auto; max-width: 100%; }
.wb-md th, .wb-md td { border: 1px solid #E5E7EB; padding: 5px 9px; text-align: left; }
.wb-md th { background: #F8F9FC; font-weight: 600; }
.wb-md code { font-family: var(--tv-mono); font-size: 13px; background: #F3F4F6;
  color: #db2777; padding: 1px 5px; border-radius: 4px; }
.wb-md pre { margin: 8px 0; padding: 12px 14px; background: #0f172a;
  border-radius: 8px; overflow-x: auto; }
.wb-md pre code { background: transparent; color: #e2e8f0; padding: 0;
  font-size: 13px; line-height: 1.55; }

.wb-pre { margin: 4px 0 0; padding: 10px 12px; background: #0f172a; color: #e2e8f0;
  border-radius: 8px; font-family: var(--tv-mono); font-size: 13px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word; overflow-x: auto; }
.wb-pre.fail { color: #fca5a5; }
.wb-pre.scrolly { max-height: 280px; overflow-y: auto; }
.wb-pre.scrolly-tall { max-height: 320px; overflow-y: auto; }
.wb-pre.small { max-height: 240px; overflow-y: auto; margin: 2px 0 6px 18px; }

.wb-phase { font-size: 13px; color: #9ca3af; margin: 6px 0; display: flex;
  align-items: center; gap: 6px; }
.wb-phase.cur { color: var(--tv-primary); }

.wb-cursor { display: inline-block; width: 7px; height: 13px; background: #6366F1;
  margin-left: 2px; vertical-align: text-bottom;
  animation: wb-blink 1s steps(2, start) infinite; }
@keyframes wb-blink { to { visibility: hidden; } }

.wb-proc { font-size: 13px; color: #9ca3af; display: flex; align-items: center;
  gap: 6px; padding: 2px 0; cursor: pointer; min-width: 0; }
.wb-proc:hover { color: #6b7280; }
.wb-proc .chev { margin-left: auto; flex-shrink: 0; font-size: 12px; transition: transform .15s; }
.wb-proc .chev.open { transform: rotate(180deg); }
.wb-proc-detail { margin-left: 18px; }
.wb-proc-label { color: #6b7280; font-weight: 500; }
.wb-proc-lbl { color: #6b7280; font-size: 12px; margin: 2px 0; }

.wb-proc-group { margin: 2px 0; }
.wb-proc-group-body { margin: 4px 0 2px; }

.wb-skill-chip { display: inline-block; background: #eef2ff; color: #4338ca;
  border: 1px solid #c7d2fe; border-radius: 6px; padding: 0 6px; margin: 0 2px;
  font-size: 13px; line-height: 1.5; user-select: none; cursor: default; }
.wb-agent-chip { display: inline-block; background: #f3e8ff; color: #6d28d9;
  border: 1px solid #d8b4fe; border-radius: 6px; padding: 0 6px; margin: 0 2px;
  font-size: 13px; line-height: 1.5; user-select: none; cursor: default; }
.wb-file-chip { display: inline-block; background: #ecfeff; color: #0e7490;
  border: 1px solid #a5f3fc; border-radius: 6px; padding: 0 6px; margin: 0 2px;
  font-size: 13px; line-height: 1.5; user-select: none; cursor: default; }
.wb-file-chip::before { content: '@'; opacity: 0.55; margin-right: 2px; }

.tv-thinking { display: inline-block; width: 13px; height: 13px; flex: 0 0 auto;
  border: 2px solid #d1d5db; border-top-color: var(--tv-primary);
  border-radius: 50%; animation: tvspin 0.8s linear infinite; }
@keyframes tvspin { to { transform: rotate(360deg); } }

.tv-note-line { margin: 2px 0; cursor: pointer; font-size: 13px; color: #9ca3af;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-note-open { margin: 4px 0 8px; border: 1px solid var(--tv-border);
  border-radius: 8px; background: #FAFBFC; padding: 6px 10px; }
.tv-note-open .cap { cursor: pointer; font-size: 12px; color: #9ca3af; margin-bottom: 4px; }

.tv-changes-box { border: 1px solid var(--tv-border); border-radius: 8px;
  background: #FAFBFC; margin-top: 10px; }
.tv-changes-head { display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  cursor: pointer; font-size: 13px; }
.tv-changes-head .cnt { background: #e6f7ff; color: #1677ff; border: 1px solid #91d5ff;
  border-radius: 4px; font-size: 12px; padding: 0 6px; line-height: 18px; }
.tv-changes-head .rt { margin-left: auto; color: #9ca3af; font-size: 12px; }
.tv-changes-body { padding: 4px 10px 10px; border-top: 1px solid var(--tv-border); }
.tv-changes-row { display: flex; align-items: center; gap: 6px; padding: 4px 0;
  font-size: 13px; }
.tv-changes-row a { color: var(--tv-primary); cursor: pointer; word-break: break-all;
  text-decoration: none; }
.tv-changes-row a:hover { text-decoration: underline; }

/* ── 抽屉（任务配置 / 条目查看） ───────────────────────────────── */
.tv-drawer-mask { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.30);
  z-index: 70; display: flex; justify-content: flex-end; }
.tv-drawer { width: 460px; max-width: 92vw; background: #fff; height: 100%;
  display: flex; flex-direction: column; box-shadow: -6px 0 20px rgba(0, 0, 0, 0.10); }
.tv-drawer-head { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--tv-border); }
.tv-drawer-head .t { font-size: 15px; font-weight: 600; color: #111827; }
.tv-drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.tv-drawer-foot { padding: 12px 20px; border-top: 1px solid var(--tv-border);
  display: flex; justify-content: flex-end; gap: 8px; }
.tv-field { margin-bottom: 14px; }
.tv-field label { display: block; font-size: 13px; color: #6b7280; margin-bottom: 6px; }
.tv-field select, .tv-field input[type=text], .tv-field textarea {
  width: 100%; height: 32px; border: 1px solid var(--tv-border); border-radius: 6px;
  padding: 0 8px; font-size: 13px; font-family: var(--tv-font); outline: none;
  background: #fff; color: #1f2937; }
.tv-field textarea { height: auto; padding: 8px; resize: vertical; }
.tv-field select:focus, .tv-field input:focus { border-color: var(--tv-primary); }
.tv-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--tv-border);
  background: #fff; cursor: pointer; font-size: 13px; font-family: var(--tv-font);
  color: #374151; }
.tv-btn:hover { border-color: #d1d5db; color: #111827; }
.tv-btn.primary { background: var(--tv-primary); border-color: var(--tv-primary); color: #fff; }
.tv-btn.primary:hover { background: #4f52e8; }
.tv-btn.danger { color: #ff3b30; border-color: #fecaca; }
.tv-btn.sm { height: 26px; padding: 0 10px; font-size: 12px; }

/* ── 知识库 Hub（三栏 Finder 式） ─────────────────────────────── */
.tv-hub { flex: 1; display: flex; flex-direction: column; min-height: 0; background: #fff; }
.tv-hub-body { flex: 1; display: flex; min-height: 0; }
.tv-hub-cats { flex: 0 0 150px; background: #F5F5F7; border-right: 1px solid var(--tv-border);
  overflow-y: auto; padding: 8px 0; }
.tv-hub-side-header { font-size: 11px; font-weight: 600; color: #86868b;
  letter-spacing: 0.4px; text-transform: uppercase; padding: 6px 14px 4px; }
.tv-hub-cat { display: flex; align-items: center; height: 32px; margin: 1px 6px;
  padding: 0 10px; border-radius: 6px; cursor: pointer; font-size: 13px;
  user-select: none; background: transparent; }
.tv-hub-cat:hover { background: #ECECEF; }
.tv-hub-cat.active { background: #E8EAFE; }
.tv-hub-cat span { flex: 1; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: #1d1d1f; }
.tv-hub-cat.active span { color: var(--tv-primary); font-weight: 600; }
.tv-hub-hint { padding: 10px 14px 0; font-size: 11px; color: #aeaeb2; line-height: 1.6; }

.tv-hub-scope { flex: 2; min-width: 188px; max-width: 264px; background: #fff;
  border-right: 1px solid var(--tv-border); overflow-y: auto; padding: 8px 0; }
.tv-hub-tree-row { display: flex; align-items: center; gap: 6px; height: 30px;
  margin: 1px 6px; padding: 0 8px; border-radius: 6px; cursor: pointer;
  font-size: 13px; line-height: 1; user-select: none; background: transparent; }
.tv-hub-tree-row:hover { background: #ECECEF; }
.tv-hub-tree-row.active { background: #E8EAFE; }
.tv-hub-tree-row .tw { width: 12px; display: inline-flex; justify-content: center;
  flex: 0 0 12px; font-size: 9px; color: #86868b; cursor: pointer;
  transition: transform .15s; }
.tv-hub-tree-row .tw.open { transform: rotate(90deg); }
.tv-hub-tree-row .ic { font-size: 14px; flex: 0 0 auto; color: #86868b; }
.tv-hub-tree-row.active .ic { color: var(--tv-primary); }
.tv-hub-tree-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: #1d1d1f; }
.tv-hub-tree-row.active .nm { color: var(--tv-primary); font-weight: 600; }
.tv-hub-pill { font-size: 10px; color: #86868b; background: rgba(0, 0, 0, 0.06);
  padding: 1px 6px; border-radius: 8px; flex: 0 0 auto; line-height: 14px; }

.tv-hub-main { flex: 7; min-width: 0; display: flex; flex-direction: column;
  background: #fff; border-left: 1px solid var(--tv-border); }
.tv-hub-toolbar { display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--tv-border); flex: 0 0 auto;
  gap: 8px; flex-wrap: wrap; background: #fbfbfd; }
.tv-hub-toolbar .lt { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.tv-hub-toolbar .lt .cat { font-size: 13px; font-weight: 600; color: #1d1d1f; }
.tv-hub-toolbar .lt .sc { font-size: 12px; color: #86868b; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.tv-hub-toolbar .ops { display: flex; gap: 8px; flex: 0 0 auto; }
.tv-tool-btn { display: inline-flex; align-items: center; gap: 5px; font-size: 12px;
  color: #1d1d1f; background: #eef0f3; border: none; cursor: pointer;
  padding: 5px 10px; border-radius: 6px; height: 28px; white-space: nowrap;
  font-family: var(--tv-font); }
.tv-tool-btn.primary { color: #fff; background: var(--tv-primary); }
.tv-tool-btn.danger { color: #ff3b30; }
.tv-tool-btn:disabled { color: #d1d5db; cursor: not-allowed; }

.tv-hub-list { flex: 1; overflow-y: auto; }
.tv-entry-row { display: grid; grid-template-columns: minmax(160px, 2.2fr) 1fr 90px 110px;
  gap: 8px; align-items: center; padding: 0 16px; height: 32px; cursor: pointer;
  font-size: 13px; color: #1d1d1f; border-bottom: 1px solid #f3f4f6; }
.tv-entry-row:hover { background: #f7f8fa; }
.tv-entry-row.selected { background: #E8EAFE; }
.tv-entry-row .nm { display: flex; align-items: center; gap: 5px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.tv-entry-row .tw { width: 10px; flex: 0 0 10px; color: #86868b; font-size: 9px;
  transition: transform .15s; }
.tv-entry-row .tw.open { transform: rotate(90deg); }
.tv-entry-row .ty, .tv-entry-row .sz, .tv-entry-row .tm { color: #6b7280;
  font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-hub-empty { padding: 48px 16px; text-align: center; color: #9ca3af; font-size: 13px; }
.tv-hub-loading { padding: 48px; text-align: center; color: #9ca3af; font-size: 13px; }
.tv-entry-head, .tv-entry-row { padding-left: 16px; }
.tv-entry-head { display: grid; grid-template-columns: minmax(160px, 2.2fr) 1fr 90px 110px;
  gap: 8px; padding: 0 16px 6px; font-size: 11px; color: #86868b; font-weight: 600;
  border-bottom: 1px solid var(--tv-border); position: sticky; top: 0;
  background: #fff; z-index: 1; }

/* ── 通用轻量模态 ─────────────────────────────────────────────── */
.tv-modal-mask { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35);
  z-index: 80; display: flex; align-items: center; justify-content: center; }
.tv-modal { background: #fff; border-radius: 10px; width: 420px; max-width: 92vw;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18); padding: 20px; }
.tv-modal h3 { margin: 0 0 8px; font-size: 15px; color: #111827; }
.tv-modal .desc { font-size: 12px; color: #9ca3af; margin-bottom: 12px; }
.tv-modal .ops { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ── toast ───────────────────────────────────────────────────── */
#tv-toast { position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.tv-toast-item { background: #fff; border: 1px solid var(--tv-border);
  border-radius: 8px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10); padding: 8px 14px;
  font-size: 13px; color: #1f2937; max-width: 70vw; }
.tv-toast-item.err { border-color: #fecaca; color: #dc2626; }
.tv-toast-item.ok { border-color: #bbf7d0; color: #16a34a; }
