/* ============================================
   Workbench - Dark Theme CSS
   Based on design draft variables
   ============================================ */

:root {
  --wb-background: #0f1117;
  --wb-foreground: #e6e8ef;
  --wb-card: #161922;
  --wb-card-foreground: #e6e8ef;
  --wb-popover: #1c2030;
  --wb-primary: #6366f1;
  --wb-primary-foreground: #ffffff;
  --wb-secondary: #252a3a;
  --wb-secondary-foreground: #e6e8ef;
  --wb-muted: #1e2230;
  --wb-muted-foreground: #8b90a5;
  --wb-accent: #2a2f45;
  --wb-accent-foreground: #e6e8ef;
  --wb-destructive: #ef4444;
  --wb-destructive-foreground: #ffffff;
  --wb-border: #262b3d;
  --wb-input: #262b3d;
  --wb-ring: #6366f1;

  --wb-radius-sm: 4px;
  --wb-radius-md: 8px;
  --wb-radius-lg: 12px;

  --wb-state-success: #22c55e;
  --wb-state-warning: #f59e0b;
  --wb-state-error: #ef4444;
  --wb-state-info: #3b82f6;

  --wb-font-sans: 'Inter', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html {
  font-family: var(--wb-font-sans);
  background: var(--wb-background);
  color: var(--wb-foreground);
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  font-size: 14px;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--wb-border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--wb-muted-foreground); }

/* ========== Layout ========== */
.wb-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.wb-sidebar {
  width: 240px;
  flex-shrink: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--wb-border);
  background: var(--wb-card);
  display: flex;
  flex-direction: column;
}

.wb-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 56px;
  border-bottom: 1px solid var(--wb-border);
}

.wb-sidebar-logo .wb-logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--wb-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.wb-sidebar-logo span {
  font-weight: 600;
  font-size: 16px;
}

.wb-sidebar .wb-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wb-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--wb-muted-foreground);
  transition: all 0.15s;
  font-size: 14px;
}

.wb-nav-item:hover {
  background: var(--wb-accent);
  color: var(--wb-foreground);
}

.wb-nav-item.active {
  background: var(--wb-accent);
  color: var(--wb-foreground);
}

.wb-nav-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--wb-muted-foreground);
  padding: 12px 12px 6px;
  margin-top: 8px;
}

.wb-sidebar-user {
  padding: 12px;
  border-top: 1px solid var(--wb-border);
}

.wb-sidebar-user .user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.wb-sidebar-user .user-card:hover { background: var(--wb-accent); }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--wb-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: 500;
}

.user-info { flex: 1; min-width: 0; }
.user-info .name { font-size: 14px; font-weight: 500; }
.user-info .role { font-size: 12px; color: var(--wb-muted-foreground); }

.wb-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.wb-toolbar {
  height: 56px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--wb-border);
  background: var(--wb-card);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}

.wb-search {
  position: relative;
  width: 280px;
}

.wb-search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 36px;
  border-radius: 8px;
  border: 1px solid var(--wb-border);
  background: var(--wb-muted);
  color: var(--wb-foreground);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.wb-search input:focus { border-color: var(--wb-primary); }

.wb-search .wb-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--wb-muted-foreground);
}

.wb-toolbar .wb-spacer { flex: 1; }

.wb-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  color: inherit;
}

.wb-btn-primary {
  background: var(--wb-primary);
  color: var(--wb-primary-foreground);
}

.wb-btn-primary:hover {
  opacity: 0.9;
}

.wb-btn-ghost {
  background: transparent;
  color: var(--wb-muted-foreground);
}

.wb-btn-ghost:hover {
  background: var(--wb-accent);
  color: var(--wb-foreground);
}

.wb-btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.wb-btn-danger {
  background: var(--wb-destructive);
  color: var(--wb-destructive-foreground);
}

.wb-btn-outline {
  background: transparent;
  border: 1px solid var(--wb-border);
  color: var(--wb-foreground);
}

.wb-btn-outline:hover { border-color: var(--wb-primary); }

.wb-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.wb-grid {
  display: grid;
  gap: 24px;
}

.wb-grid-2 { grid-template-columns: 1fr 1fr; }
.wb-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

@media (max-width: 1024px) {
  .wb-grid-2, .wb-grid-3 { grid-template-columns: 1fr; }
}

.wb-card {
  background: var(--wb-card);
  border: 1px solid var(--wb-border);
  border-radius: var(--wb-radius-lg);
  padding: 20px;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.wb-card:hover {
  border-color: var(--wb-primary);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.1);
}

.wb-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.wb-card-title {
  font-size: 15px;
  font-weight: 600;
}

/* ========== Stats ========== */
.wb-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.wb-stat-card {
  background: var(--wb-card);
  border: 1px solid var(--wb-border);
  border-radius: var(--wb-radius-lg);
  padding: 16px;
}

.wb-stat-label {
  font-size: 12px;
  color: var(--wb-muted-foreground);
  margin-bottom: 6px;
}

.wb-stat-value {
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ========== Project Selector ========== */
.project-selector {
  margin-bottom: 20px;
}

.project-selector select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--wb-border);
  background: var(--wb-muted);
  color: var(--wb-foreground);
  font-size: 14px;
  outline: none;
  cursor: pointer;
}

.project-selector select:focus { border-color: var(--wb-primary); }

/* ========== Task List ========== */
.wb-task-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wb-task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  padding-left: calc(12px + var(--depth, 0) * 22px);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.wb-task-item:hover { background: var(--wb-accent); }

/* ========== 任务树（流树结构） ========== */
.wb-tree-toggle {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--wb-muted-foreground);
  cursor: pointer;
  flex-shrink: 0;
}
.wb-tree-toggle:not(.leaf):hover {
  background: var(--wb-border);
  color: var(--wb-foreground);
}
.wb-tree-toggle.leaf { cursor: default; }
.wb-tree-toggle .wb-tree-arrow {
  transform: rotate(0deg);
  transition: transform 0.15s;
}
.wb-task-item.collapsed .wb-tree-arrow { transform: rotate(0deg); }
.wb-task-item:not(.collapsed) .wb-tree-toggle .wb-tree-arrow { transform: rotate(90deg); }

.wb-task-children {
  position: relative;
  margin-left: calc(21px + var(--parent-depth, 0) * 22px);
  border-left: 1.5px dashed var(--wb-border);
  padding-left: 6px;
}

.wb-sub-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 9px;
  background: var(--wb-accent);
  border: 1px solid var(--wb-border);
  color: var(--wb-muted-foreground);
  font-size: 11px;
  font-weight: 500;
  vertical-align: middle;
}

/* ========== 完成来源徽标 ========== */
.wb-badge-src-1 {
  background: rgba(99, 102, 241, 0.12);
  color: #6366f1;
  border: 1px solid rgba(99, 102, 241, 0.3);
}
.wb-badge-src-2 {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.wb-badge-src-3 {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* ========== 完成来源菜单 ========== */
.wb-complete-menu {
  position: fixed;
  z-index: 2000;
  min-width: 200px;
  background: var(--wb-card);
  border: 1px solid var(--wb-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  padding: 6px;
  animation: wbFadeIn 0.15s;
}
.wb-complete-menu-title {
  font-size: 11px;
  color: var(--wb-muted-foreground);
  padding: 4px 10px 6px;
  border-bottom: 1px solid var(--wb-border);
  margin-bottom: 4px;
}
.wb-complete-menu-item {
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
}
.wb-complete-menu-item:hover { background: var(--wb-accent); }

.wb-checkbox {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--wb-border);
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  background: transparent;
}

.wb-checkbox:hover { border-color: var(--wb-primary); }
.wb-checkbox.checked { background: var(--wb-primary); border-color: var(--wb-primary); }

.wb-task-body { flex: 1; min-width: 0; }

.wb-task-title {
  font-size: 14px;
  margin-bottom: 4px;
}

.wb-task-title.completed {
  color: var(--wb-muted-foreground);
  text-decoration: line-through;
}

.wb-task-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--wb-muted-foreground);
}

.wb-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.wb-badge-success { background: rgba(34, 197, 94, 0.15); color: var(--wb-state-success); }
.wb-badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--wb-state-warning); }
.wb-badge-error   { background: rgba(239, 68, 68, 0.15); color: var(--wb-state-error); }
.wb-badge-info    { background: rgba(59, 130, 246, 0.15); color: var(--wb-state-info); }
.wb-badge-primary { background: rgba(99, 102, 241, 0.15); color: var(--wb-primary); }

.wb-badge-ai-processing { background: rgba(99, 102, 241, 0.15); color: var(--wb-primary); }
.wb-badge-ai-completed  { background: rgba(34, 197, 94, 0.15); color: var(--wb-state-success); }
.wb-badge-manual-test   { background: rgba(59, 130, 246, 0.15); color: var(--wb-state-info); }
.wb-badge-blocked       { background: rgba(239, 68, 68, 0.15); color: var(--wb-state-error); }

/* ========== Progress ========== */
.wb-progress-card {
  padding: 12px;
  background: var(--wb-muted);
  border: 1px solid var(--wb-border);
  border-radius: 8px;
  margin-bottom: 10px;
  position: relative;
  overflow: hidden;
}

.wb-progress-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}

.wb-progress-card.running::before { background: var(--wb-state-success); }
.wb-progress-card.blocked::before { background: var(--wb-state-error); }
.wb-progress-card.done::before    { background: var(--wb-state-info); }

.wb-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.wb-progress-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
}

.wb-progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.wb-progress-dot.running { background: var(--wb-state-success); box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
.wb-progress-dot.blocked { background: var(--wb-state-error); }
.wb-progress-dot.done    { background: var(--wb-state-info); }

.wb-progress-bar {
  height: 6px;
  background: var(--wb-border);
  border-radius: 3px;
  overflow: hidden;
}

.wb-progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.wb-progress-fill.running { background: var(--wb-state-success); }
.wb-progress-fill.blocked { background: var(--wb-state-error); }
.wb-progress-fill.done    { background: var(--wb-state-info); }

.wb-progress-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--wb-muted-foreground);
}

/* ========== State Machine ========== */
.wb-state-flow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  margin-bottom: 16px;
}

.wb-state-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: 0.4;
}

.wb-state-node.active { opacity: 1; }

.wb-state-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--wb-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--wb-muted-foreground);
  border: 1px solid var(--wb-border);
}

.wb-state-node.active .wb-state-icon {
  background: var(--wb-primary);
  color: var(--wb-primary-foreground);
  border-color: var(--wb-primary);
}

.wb-state-label {
  font-size: 12px;
  color: var(--wb-muted-foreground);
}

.wb-state-count {
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.wb-state-connector {
  width: 40px;
  height: 2px;
  background: var(--wb-border);
  margin-bottom: 24px;
}

.wb-state-connector.active { background: var(--wb-primary); }

/* ========== Modal ========== */
.wb-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.wb-modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.wb-modal {
  background: var(--wb-card);
  border: 1px solid var(--wb-border);
  border-radius: var(--wb-radius-lg);
  padding: 24px;
  min-width: 420px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform 0.2s;
}

.wb-modal-overlay.show .wb-modal { transform: scale(1); }

.wb-modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
}

.wb-form-group {
  margin-bottom: 16px;
}

.wb-form-label {
  display: block;
  font-size: 13px;
  color: var(--wb-muted-foreground);
  margin-bottom: 6px;
}

.wb-form-input,
.wb-form-select,
.wb-form-textarea {
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--wb-border);
  background: var(--wb-muted);
  color: var(--wb-foreground);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}

.wb-form-input:focus,
.wb-form-select:focus,
.wb-form-textarea:focus {
  border-color: var(--wb-primary);
}

.wb-form-textarea {
  resize: vertical;
  min-height: 80px;
}

.wb-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.wb-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* ========== Tabs ========== */
.wb-tabs {
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--wb-muted);
  border-radius: 8px;
  margin-bottom: 16px;
}

.wb-tab {
  flex: 1;
  padding: 6px 12px;
  text-align: center;
  border-radius: 6px;
  font-size: 13px;
  color: var(--wb-muted-foreground);
  cursor: pointer;
  transition: all 0.15s;
}

.wb-tab.active {
  background: var(--wb-card);
  color: var(--wb-foreground);
}

.wb-tab:hover:not(.active) { color: var(--wb-foreground); }

/* ========== Table ========== */
.wb-table {
  width: 100%;
  border-collapse: collapse;
}

.wb-table th {
  text-align: left;
  padding: 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--wb-muted-foreground);
  border-bottom: 1px solid var(--wb-border);
}

.wb-table td {
  padding: 12px;
  font-size: 14px;
  border-bottom: 1px solid var(--wb-border);
}

.wb-table tr:last-child td { border-bottom: none; }
.wb-table tr:hover td { background: var(--wb-accent); }

/* ========== Utility ========== */
.wb-hidden { display: none !important; }
.wb-empty {
  text-align: center;
  padding: 40px;
  color: var(--wb-muted-foreground);
  font-size: 13px;
}
.wb-fade-in { animation: wbFadeIn 0.3s; }

@keyframes wbFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== Notes (便签笔记) ========== */
.wb-notes-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.wb-notes-toolbar select {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--wb-border);
  background: var(--wb-muted);
  color: var(--wb-foreground);
  font-size: 14px;
  outline: none;
  cursor: pointer;
}

.wb-notes-toolbar select:focus { border-color: var(--wb-primary); }

.wb-note-type-tabs {
  flex: 1;
  min-width: 380px;
  max-width: 560px;
  margin-bottom: 0;
}

.wb-note-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  align-items: stretch;
}

.wb-note-card {
  --note-color: var(--wb-primary);
  position: relative;
  background: var(--wb-card);
  border: 1px solid var(--wb-border);
  border-radius: var(--wb-radius-lg);
  padding: 16px 16px 12px 20px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 150px;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

/* 左侧类型色条 */
.wb-note-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--note-color);
  opacity: 0.85;
}

.wb-note-card:hover {
  transform: translateY(-3px);
  border-color: var(--note-color);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

/* 置顶卡片：类型色描边 */
.wb-note-card.pinned {
  border-color: var(--note-color);
  box-shadow: 0 0 0 1px var(--note-color), 0 4px 16px rgba(0, 0, 0, 0.3);
}

.wb-note-card.pinned::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--note-color) 8%, transparent), transparent 40%);
  pointer-events: none;
}

.wb-note-pin {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 14px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}

.wb-note-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  padding-right: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.wb-note-content {
  font-size: 12.5px;
  color: var(--wb-muted-foreground);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  flex: 1;
}

.wb-note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.wb-note-tag {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--wb-muted);
  border: 1px solid var(--wb-border);
  color: var(--wb-muted-foreground);
}

.wb-note-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
}

.wb-note-type-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--note-color) 15%, transparent);
  color: var(--note-color);
  border: 1px solid color-mix(in srgb, var(--note-color) 35%, transparent);
}

.wb-note-meta {
  font-size: 11px;
  color: var(--wb-muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wb-note-actions {
  display: flex;
  gap: 6px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s, transform 0.15s;
}

.wb-note-card:hover .wb-note-actions {
  opacity: 1;
  transform: translateY(0);
}

.wb-note-btn {
  flex: 1;
  padding: 4px 0;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--wb-border);
  background: var(--wb-muted);
  color: var(--wb-muted-foreground);
  cursor: pointer;
  transition: all 0.15s;
}

.wb-note-btn:hover {
  border-color: var(--wb-primary);
  color: var(--wb-primary);
}

.wb-note-btn.danger:hover {
  border-color: var(--wb-destructive);
  color: var(--wb-destructive);
}

@media (max-width: 1024px) {
  .wb-note-type-tabs { min-width: 100%; }
}

/* ========== 登录 / 注册页 ========== */
.wb-auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #1b2035 0%, var(--wb-background) 45%),
              radial-gradient(circle at 80% 80%, #1e2438 0%, var(--wb-background) 40%);
  padding: 24px;
}

.wb-auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--wb-card);
  border: 1px solid var(--wb-border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  animation: wbFadeIn 0.35s;
}

.wb-auth-logo { text-align: center; margin-bottom: 24px; }
.wb-auth-logo .wb-logo-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  border-radius: 12px;
  background: var(--wb-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.wb-auth-logo h1 { font-size: 20px; margin: 0 0 6px; }
.wb-auth-logo p { font-size: 13px; color: var(--wb-muted-foreground); margin: 0; }

.wb-auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--wb-muted);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 20px;
}
.wb-auth-tab {
  flex: 1;
  text-align: center;
  padding: 8px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--wb-muted-foreground);
  transition: all 0.15s;
}
.wb-auth-tab.active {
  background: var(--wb-primary);
  color: var(--wb-primary-foreground);
  font-weight: 500;
}

.wb-auth-form .wb-form-group { margin-bottom: 14px; }

.wb-auth-error {
  min-height: 18px;
  font-size: 12px;
  color: var(--wb-destructive);
  margin-bottom: 8px;
}

.wb-auth-submit { width: 100%; justify-content: center; padding: 10px; }

.wb-auth-hint {
  font-size: 12px;
  color: var(--wb-muted-foreground);
  text-align: center;
  margin-top: 12px;
}

/* ========== 侧边栏用户卡片 ========== */
.user-card-caret {
  color: var(--wb-muted-foreground);
  flex-shrink: 0;
}
.user-avatar.has-image {
  background: none;
  overflow: hidden;
  padding: 0;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ========== 用户下拉菜单 ========== */
.wb-user-menu {
  position: fixed;
  z-index: 2000;
  min-width: 210px;
  background: var(--wb-card);
  border: 1px solid var(--wb-border);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  padding: 6px;
  animation: wbFadeIn 0.15s;
}
.wb-user-menu-head {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--wb-border);
  margin-bottom: 4px;
}
.wb-user-menu-name { font-size: 13px; font-weight: 500; }
.wb-user-menu-sub {
  font-size: 11px;
  color: var(--wb-muted-foreground);
  margin-top: 2px;
}
.wb-user-menu-item {
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.wb-user-menu-item:hover { background: var(--wb-accent); }
.wb-user-menu-item.danger { color: var(--wb-destructive); }
.wb-user-menu-item.danger:hover { background: rgba(239, 68, 68, 0.12); }
.wb-user-menu-sep {
  height: 1px;
  background: var(--wb-border);
  margin: 4px 0;
}

/* ========== 个人信息设置 ========== */
.wb-profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--wb-muted);
  border-radius: 10px;
  margin-bottom: 18px;
}
.wb-profile-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--wb-primary);
  color: var(--wb-primary-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  flex-shrink: 0;
}
.wb-profile-avatar.has-image { background: none; overflow: hidden; }
.wb-profile-avatar img { width: 100%; height: 100%; object-fit: cover; }

#profileModal .wb-form-textarea { min-height: 70px; }


/* ============================================
   知识库 Wiki
   ============================================ */
.wb-wiki {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 0;
    height: calc(100vh - 140px);
    min-height: 520px;
    border: 1px solid var(--wb-border);
    border-radius: var(--wb-radius-lg);
    overflow: hidden;
    background: var(--wb-card);
}

/* ---------- 左侧目录 ---------- */
.wb-wiki-sidebar {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--wb-border);
    background: var(--wb-muted);
    min-width: 0;
    overflow: hidden;
}
.wb-wiki-sidebar-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px 8px;
}
.wb-wiki-sidebar-title {
    font-size: 12px; font-weight: 600; letter-spacing: .08em;
    text-transform: uppercase; color: var(--wb-muted-foreground);
}
.wb-wiki-sidebar-actions { display: flex; gap: 4px; }

.wb-icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; padding: 0;
    background: transparent; border: 1px solid transparent;
    border-radius: var(--wb-radius-sm);
    color: var(--wb-muted-foreground); cursor: pointer;
    transition: all .15s;
}
.wb-icon-btn:hover { background: var(--wb-accent); color: var(--wb-foreground); }

.wb-wiki-search {
    position: relative; display: flex; align-items: center; gap: 7px;
    margin: 0 12px 10px; padding: 7px 10px;
    background: var(--wb-input); border: 1px solid var(--wb-border);
    border-radius: var(--wb-radius-md);
    color: var(--wb-muted-foreground);
    transition: border-color .15s;
}
.wb-wiki-search:focus-within { border-color: var(--wb-ring); }
.wb-wiki-search input {
    flex: 1; min-width: 0; background: transparent; border: none; outline: none;
    color: var(--wb-foreground); font-size: 13px; font-family: inherit;
}
.wb-wiki-search input::placeholder { color: var(--wb-muted-foreground); }
.wb-wiki-search input::-webkit-search-cancel-button { display: none; }
.wb-wiki-search-clear {
    background: transparent; border: none; cursor: pointer;
    color: var(--wb-muted-foreground); font-size: 17px; line-height: 1; padding: 0 2px;
}
.wb-wiki-search-clear:hover { color: var(--wb-foreground); }

.wb-wiki-tree, .wb-wiki-results {
    flex: 1; overflow-y: auto; padding: 0 8px 14px;
}
.wb-wiki-results { padding-top: 2px; }

/* 目录树节点 */
.wb-wiki-node {
    display: flex; align-items: center; gap: 5px;
    padding: 5px 8px; border-radius: var(--wb-radius-sm);
    cursor: pointer; user-select: none;
    font-size: 13px; color: var(--wb-foreground);
    transition: background .12s;
}
.wb-wiki-node:hover { background: var(--wb-accent); }
.wb-wiki-node.active { background: var(--wb-primary); color: var(--wb-primary-foreground); }
.wb-wiki-node.active .wb-wiki-node-name { font-weight: 600; }
.wb-wiki-node-icon { flex: none; width: 15px; text-align: center; font-size: 13px; }
.wb-wiki-node-name {
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wb-wiki-node-count {
    flex: none; font-size: 11px; color: var(--wb-muted-foreground);
    background: var(--wb-secondary); border-radius: 8px; padding: 0 6px; line-height: 16px;
}
.wb-wiki-node.active .wb-wiki-node-count { background: rgba(255,255,255,.2); color: #fff; }

.wb-wiki-folder-toggle {
    flex: none; display: inline-flex; align-items: center; justify-content: center;
    width: 14px; height: 14px; background: transparent; border: none; padding: 0;
    color: var(--wb-muted-foreground); cursor: pointer;
}
.wb-wiki-arrow { transition: transform .15s; }
.wb-wiki-node:not(.collapsed) .wb-wiki-folder-toggle .wb-wiki-arrow { transform: rotate(90deg); }
.wb-wiki-children { border-left: 1px dashed var(--wb-border); margin-left: 14px; padding-left: 4px; }

.wb-wiki-empty-tree {
    padding: 24px 12px; text-align: center;
    font-size: 12px; color: var(--wb-muted-foreground);
}

/* 搜索结果 */
.wb-wiki-result {
    padding: 9px 10px; margin-bottom: 5px;
    background: var(--wb-card); border: 1px solid var(--wb-border);
    border-radius: var(--wb-radius-md); cursor: pointer;
    transition: border-color .15s, background .15s;
}
.wb-wiki-result:hover { border-color: var(--wb-ring); background: var(--wb-accent); }
.wb-wiki-result-title { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.wb-wiki-result-path {
    font-size: 11px; color: var(--wb-muted-foreground); margin-bottom: 4px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wb-wiki-result-snippet {
    font-size: 12px; color: var(--wb-muted-foreground); line-height: 1.5;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.wb-wiki-result-snippet mark {
    background: rgba(99,102,241,.32); color: var(--wb-foreground);
    border-radius: 2px; padding: 0 2px;
}
.wb-wiki-result-count { font-size: 11px; color: var(--wb-primary); margin-left: 6px; }
.wb-wiki-results-head {
    font-size: 11px; color: var(--wb-muted-foreground);
    padding: 4px 6px 8px;
}

/* ---------- 右侧文档区 ---------- */
.wb-wiki-main {
    display: flex; flex-direction: column; min-width: 0; overflow: hidden;
}
.wb-wiki-empty {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 14px;
    color: var(--wb-muted-foreground); font-size: 14px;
}
.wb-wiki-empty p { margin: 0; }

.wb-wiki-doc-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 20px; border-bottom: 1px solid var(--wb-border);
    flex-wrap: wrap;
}
.wb-wiki-crumb { display: flex; align-items: center; gap: 8px; min-width: 0; }
.wb-wiki-crumb > span { font-size: 17px; }
.wb-wiki-breadcrumb {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    font-size: 13px; color: var(--wb-muted-foreground); min-width: 0;
}
.wb-wiki-breadcrumb .sep { opacity: .5; }
.wb-wiki-breadcrumb .cur { color: var(--wb-foreground); font-weight: 600; }

.wb-wiki-doc-tools { display: flex; align-items: center; gap: 8px; }

/* 分段控件：预览 / 编辑 */
.wb-segmented {
    display: inline-flex; padding: 2px;
    background: var(--wb-muted); border: 1px solid var(--wb-border);
    border-radius: var(--wb-radius-md);
}
.wb-segmented-btn {
    padding: 5px 14px; font-size: 12px; font-family: inherit;
    background: transparent; border: none; border-radius: 6px;
    color: var(--wb-muted-foreground); cursor: pointer;
    transition: all .15s;
}
.wb-segmented-btn:hover { color: var(--wb-foreground); }
.wb-segmented-btn.active {
    background: var(--wb-primary); color: var(--wb-primary-foreground); font-weight: 600;
}
.wb-btn-danger { color: var(--wb-destructive); border-color: rgba(239,68,68,.35); }
.wb-btn-danger:hover { background: rgba(239,68,68,.12); }

.wb-wiki-meta {
    padding: 7px 20px; font-size: 11px; color: var(--wb-muted-foreground);
    border-bottom: 1px solid var(--wb-border);
}

#wikiPreview, .wb-wiki-editor-wrap {
    flex: 1; overflow-y: auto; padding: 22px 28px 60px;
}
.wb-wiki-editor-wrap { padding: 0; display: flex; }
.wb-wiki-editor {
    flex: 1; width: 100%; min-height: 100%; resize: none;
    padding: 22px 28px 60px;
    background: var(--wb-background); border: none; outline: none;
    color: var(--wb-foreground);
    font-family: 'JetBrains Mono', 'Cascadia Code', Consolas, 'Courier New', monospace;
    font-size: 13.5px; line-height: 1.75; tab-size: 2;
}

/* ---------- Markdown 正文排版 ---------- */
.wb-markdown { line-height: 1.75; font-size: 14.5px; color: var(--wb-card-foreground); }
.wb-markdown > *:first-child { margin-top: 0; }
.wb-markdown h1, .wb-markdown h2, .wb-markdown h3,
.wb-markdown h4, .wb-markdown h5, .wb-markdown h6 {
    margin: 1.5em 0 .6em; font-weight: 700; line-height: 1.35;
    color: var(--wb-foreground);
}
.wb-markdown h1 { font-size: 1.85em; padding-bottom: .35em; border-bottom: 1px solid var(--wb-border); }
.wb-markdown h2 { font-size: 1.45em; padding-bottom: .3em; border-bottom: 1px solid var(--wb-border); }
.wb-markdown h3 { font-size: 1.2em; }
.wb-markdown h4 { font-size: 1.05em; }
.wb-markdown p { margin: .8em 0; }
.wb-markdown a { color: var(--wb-primary); text-decoration: none; }
.wb-markdown a:hover { text-decoration: underline; }
.wb-markdown strong { font-weight: 700; color: var(--wb-foreground); }
.wb-markdown ul, .wb-markdown ol { margin: .8em 0; padding-left: 1.6em; }
.wb-markdown li { margin: .35em 0; }
.wb-markdown li > input[type="checkbox"] { margin-right: .5em; }
.wb-markdown blockquote {
    margin: 1em 0; padding: .2em 1em;
    border-left: 3px solid var(--wb-primary);
    background: var(--wb-muted); color: var(--wb-muted-foreground); border-radius: 0 4px 4px 0;
}
.wb-markdown code {
    padding: .15em .4em; font-size: .88em;
    background: var(--wb-secondary); border-radius: 4px;
    font-family: 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
}
.wb-markdown pre {
    margin: 1em 0; padding: 14px 16px; overflow-x: auto;
    background: var(--wb-background); border: 1px solid var(--wb-border);
    border-radius: var(--wb-radius-md);
}
.wb-markdown pre code { padding: 0; background: transparent; font-size: 13px; line-height: 1.6; }
.wb-markdown table {
    margin: 1em 0; border-collapse: collapse; width: 100%; font-size: 13.5px;
}
.wb-markdown th, .wb-markdown td {
    padding: 8px 12px; border: 1px solid var(--wb-border); text-align: left;
}
.wb-markdown th { background: var(--wb-muted); font-weight: 600; }
.wb-markdown tr:nth-child(even) td { background: rgba(255,255,255,.02); }
.wb-markdown hr { margin: 1.8em 0; border: none; border-top: 1px solid var(--wb-border); }
.wb-markdown img { max-width: 100%; border-radius: var(--wb-radius-md); }

@media (max-width: 1100px) {
    .wb-wiki { grid-template-columns: 240px 1fr; }
}
@media (max-width: 820px) {
    .wb-wiki { grid-template-columns: 1fr; height: auto; }
    .wb-wiki-sidebar { border-right: none; border-bottom: 1px solid var(--wb-border); max-height: 340px; }
}


/* ============================================
   任务 ↔ 笔记 关联
   ============================================ */

/* 关联区通用 */
.wb-link-count {
    display: inline-block; margin-left: 6px;
    min-width: 18px; padding: 0 6px;
    background: var(--wb-secondary); border-radius: 9px;
    font-size: 11px; line-height: 17px; text-align: center;
    color: var(--wb-muted-foreground); font-weight: 600;
}

.wb-link-list {
    display: flex; flex-direction: column; gap: 5px;
    max-height: 168px; overflow-y: auto;
    margin-bottom: 7px;
}
.wb-link-list:empty { display: none; }

.wb-link-item {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 10px;
    background: var(--wb-muted); border: 1px solid var(--wb-border);
    border-radius: var(--wb-radius-md);
    transition: border-color .15s, background .15s;
}
.wb-link-item:hover { border-color: var(--wb-ring); background: var(--wb-accent); }

.wb-link-item-body {
    flex: 1; min-width: 0; cursor: pointer;
}
.wb-link-item-title {
    font-size: 13px; font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wb-link-item-sub {
    font-size: 11px; color: var(--wb-muted-foreground); margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wb-link-item-remove {
    flex: none; width: 22px; height: 22px; padding: 0;
    background: transparent; border: none; border-radius: var(--wb-radius-sm);
    color: var(--wb-muted-foreground); cursor: pointer;
    font-size: 16px; line-height: 1;
}
.wb-link-item-remove:hover { background: var(--wb-destructive); color: #fff; }

.wb-link-empty {
    padding: 9px 10px; font-size: 12px; color: var(--wb-muted-foreground);
    background: var(--wb-muted); border: 1px dashed var(--wb-border);
    border-radius: var(--wb-radius-md); text-align: center;
}

.wb-link-actions { display: flex; gap: 6px; }
.wb-link-actions .wb-form-select { flex: 1; min-width: 0; }
.wb-link-actions .wb-btn { flex: none; white-space: nowrap; }

/* 笔记卡片上的「关联任务」标签 */
.wb-note-task-tags {
    display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px;
}
.wb-note-task-tag {
    display: inline-flex; align-items: center; gap: 4px;
    max-width: 100%;
    padding: 2px 7px;
    background: rgba(99, 102, 241, .14);
    border: 1px solid rgba(99, 102, 241, .32);
    border-radius: 9px;
    font-size: 11px; color: #a5b4fc; cursor: pointer;
    transition: background .15s, border-color .15s;
}
.wb-note-task-tag:hover { background: rgba(99, 102, 241, .28); border-color: var(--wb-primary); }
.wb-note-task-tag .dot {
    flex: none; width: 5px; height: 5px; border-radius: 50%;
    background: var(--wb-primary);
}
.wb-note-task-tag .txt {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 任务行上的「笔记数」徽标 */
.wb-task-note-badge {
    display: inline-flex; align-items: center; gap: 3px;
    margin-left: 6px; padding: 1px 6px;
    background: var(--wb-secondary); border-radius: 8px;
    font-size: 11px; color: var(--wb-muted-foreground);
}
.wb-task-note-badge:hover { color: var(--wb-foreground); }

/* ===== 视图通用头（项目 / 任务 独立视图） ===== */
.wb-view-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.wb-view-title { font-size: 20px; font-weight: 600; color: var(--wb-foreground); }

/* 项目卡片网格 */
.wb-project-grid {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.wb-project-card {
    background: var(--wb-card); border: 1px solid var(--wb-border);
    border-radius: 14px; padding: 18px;
    display: flex; flex-direction: column; gap: 10px;
    transition: border-color .15s, transform .15s, box-shadow .15s;
}
.wb-project-card:hover {
    border-color: var(--wb-primary); transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.wb-project-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wb-project-name { font-size: 16px; font-weight: 600; margin: 0; color: var(--wb-foreground); }
.wb-project-desc {
    margin: 0; font-size: 13px; color: var(--wb-muted-foreground);
    line-height: 1.5; min-height: 20px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.wb-project-meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--wb-muted-foreground); }
.wb-project-actions { display: flex; gap: 8px; margin-top: 4px; }

/* 任务视图列表撑满 */
#viewTasks .wb-task-list { min-height: 200px; }
