﻿/* ============================================================
   Nexus Design System v2.0
   规范：OKLCH 色彩 / Geist 字体 / 8px 网格 / 4 级阴影
   ============================================================ */

:root {
  /* ========== 中性色（带色调，warm gray） ========== */
  --neutral-0: oklch(0.99 0.002 270);
  --neutral-50: oklch(0.98 0.003 270);
  --neutral-100: oklch(0.96 0.004 270);
  --neutral-200: oklch(0.92 0.005 270);
  --neutral-300: oklch(0.86 0.006 270);
  --neutral-400: oklch(0.72 0.008 270);
  --neutral-500: oklch(0.58 0.01 270);
  --neutral-600: oklch(0.46 0.012 270);
  --neutral-700: oklch(0.36 0.014 270);
  --neutral-800: oklch(0.24 0.012 270);
  --neutral-900: oklch(0.16 0.01 270);
  --neutral-950: oklch(0.11 0.008 270);
  --neutral-1000: oklch(0.06 0.005 270);

  /* ========== 强调色（紫蓝主调） ========== */
  --primary-50: oklch(0.97 0.018 245);
  --primary-100: oklch(0.93 0.044 245);
  --primary-200: oklch(0.88 0.07 245);
  --primary-300: oklch(0.8 0.11 245);
  --primary-400: oklch(0.7 0.15 245);
  --primary-500: oklch(0.62 0.18 245);
  --primary-600: oklch(0.54 0.2 245);
  --primary-700: oklch(0.46 0.18 245);
  --primary-800: oklch(0.38 0.14 245);
  --primary-900: oklch(0.3 0.1 245);

  --accent-purple: oklch(0.62 0.22 305);
  --accent-pink: oklch(0.68 0.2 350);
  --accent-cyan: oklch(0.7 0.15 220);
  --accent-amber: oklch(0.78 0.16 75);
  --accent-emerald: oklch(0.68 0.16 155);
  --accent-rose: oklch(0.66 0.21 25);
  --accent-blue: oklch(0.62 0.18 245);

  /* ========== 语义色 ========== */
  --success-soft: oklch(0.95 0.04 155);
  --success: oklch(0.62 0.16 155);
  --success-strong: oklch(0.5 0.18 155);
  --warning-soft: oklch(0.96 0.05 75);
  --warning: oklch(0.74 0.16 75);
  --warning-strong: oklch(0.6 0.18 75);
  --danger-soft: oklch(0.95 0.04 25);
  --danger: oklch(0.62 0.21 25);
  --danger-strong: oklch(0.5 0.22 25);
  --info-soft: oklch(0.95 0.04 245);
  --info: oklch(0.62 0.18 245);

  /* ========== 语义化 token（浅色主题默认） ========== */
  --bg: var(--neutral-50);
  --bg-elevated: oklch(1 0 0);
  --bg-raised: var(--neutral-0);
  --bg-overlay: oklch(1 0 0 / 0.8);
  --bg-subtle: var(--neutral-100);
  --bg-muted: var(--neutral-200);
  --bg-inverse: var(--neutral-900);

  --fg: var(--neutral-900);
  --fg-secondary: var(--neutral-600);
  --fg-tertiary: var(--neutral-500);
  --fg-muted: var(--neutral-400);
  --fg-inverse: var(--neutral-50);
  --fg-on-accent: var(--neutral-0);

  --border: var(--neutral-200);
  --border-strong: var(--neutral-300);
  --border-subtle: var(--neutral-100);
  --border-focus: var(--primary-500);

  --accent: var(--primary-600);
  --accent-hover: var(--primary-700);
  --accent-soft: var(--primary-50);
  --accent-soft-strong: var(--primary-100);

  /* ========== 阴影（4 级体系） ========== */
  --shadow-1: 0 1px 2px 0 oklch(0.1 0.01 270 / 0.04);
  --shadow-2: 0 2px 4px 0 oklch(0.1 0.01 270 / 0.04), 0 1px 2px 0 oklch(0.1 0.01 270 / 0.04);
  --shadow-3: 0 4px 12px -2px oklch(0.1 0.01 270 / 0.06), 0 2px 4px -2px oklch(0.1 0.01 270 / 0.04);
  --shadow-4: 0 10px 22px -6px oklch(0.1 0.01 270 / 0.07), 0 3px 8px -4px oklch(0.1 0.01 270 / 0.04);
  --shadow-5: 0 18px 36px -12px oklch(0.1 0.01 270 / 0.1), 0 6px 14px -6px oklch(0.1 0.01 270 / 0.05);
  --shadow-focus: 0 0 0 3px var(--primary-100);
  --shadow-glow: 0 0 24px -4px var(--primary-500);
  --shadow-color: 220 30% 30%;

  /* ========== 圆角 ========== */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 8px;
  --r-xl: 12px;
  --r-2xl: 18px;
  --r-3xl: 24px;
  --r-full: 999px;

  /* ========== 间距（4px 基础） ========== */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 28px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;
  --s-20: 80px;

  /* ========== 字体（Geist 优先） ========== */
  --font-sans: "Geist", "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-display: "Geist", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", "JetBrains Mono", "SF Mono", Menlo, monospace;

  /* ========== 字号梯度（modular 1.25） ========== */
  --text-xs: 11px;
  --text-sm: 12px;
  --text-base: 13px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 18px;
  --text-2xl: 22px;
  --text-3xl: 28px;
  --text-4xl: 36px;
  --text-display: 48px;

  /* ========== 行高 ========== */
  --leading-tight: 1.2;
  --leading-snug: 1.35;
  --leading-normal: 1.5;
  --leading-relaxed: 1.65;

  /* ========== 字重 ========== */
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* ========== 动效（cubic-bezier 快入慢出） ========== */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-emph: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 120ms;
  --t-mid: 200ms;
  --t-slow: 360ms;
  --t-page: 480ms;

  /* ========== 布局 ========== */
  --side-w: 72px;
  --side-expanded-w: 240px;
  --topbar-h: 56px;
  --ai-w: 360px;
  --max-w: 1280px;
}

body.density-compact {
  --s-2: 6px;
  --s-3: 10px;
  --s-4: 14px;
  --s-5: 18px;
}

body.motion-reduced *,
body.motion-reduced *::before,
body.motion-reduced *::after {
  transition-duration: 0.01ms !important;
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
}

/* ========== 暗色主题 ========== */
[data-theme="dark"] {
  --bg: var(--neutral-950);
  --bg-elevated: var(--neutral-900);
  --bg-raised: var(--neutral-900);
  --bg-overlay: oklch(0.16 0.01 270 / 0.8);
  --bg-subtle: var(--neutral-900);
  --bg-muted: var(--neutral-800);
  --bg-inverse: var(--neutral-50);

  --fg: var(--neutral-50);
  --fg-secondary: var(--neutral-300);
  --fg-tertiary: var(--neutral-400);
  --fg-muted: var(--neutral-500);
  --fg-inverse: var(--neutral-900);
  --fg-on-accent: var(--neutral-0);

  --border: var(--neutral-800);
  --border-strong: var(--neutral-700);
  --border-subtle: var(--neutral-900);
  --border-focus: var(--primary-400);

  --accent: var(--primary-400);
  --accent-hover: var(--primary-300);
  --accent-soft: oklch(0.3 0.12 280 / 0.18);
  --accent-soft-strong: oklch(0.3 0.12 280 / 0.3);

  --shadow-1: 0 1px 2px 0 oklch(0 0 0 / 0.3);
  --shadow-2: 0 2px 4px 0 oklch(0 0 0 / 0.3);
  --shadow-3: 0 4px 12px -2px oklch(0 0 0 / 0.4);
  --shadow-4: 0 12px 24px -4px oklch(0 0 0 / 0.4);
  --shadow-5: 0 24px 48px -8px oklch(0 0 0 / 0.5);
  --shadow-focus: 0 0 0 3px oklch(0.62 0.2 280 / 0.3);
  --shadow-glow: 0 0 32px -4px oklch(0.62 0.2 280 / 0.5);
}

:root[data-accent="blue"] {
  --primary-50: oklch(0.97 0.018 245);
  --primary-100: oklch(0.93 0.044 245);
  --primary-300: oklch(0.8 0.11 245);
  --primary-400: oklch(0.7 0.15 245);
  --primary-500: oklch(0.62 0.18 245);
  --primary-600: oklch(0.54 0.2 245);
  --primary-700: oklch(0.46 0.18 245);
  --accent-purple: oklch(0.66 0.18 260);
}

:root[data-accent="green"] {
  --primary-50: oklch(0.97 0.02 155);
  --primary-100: oklch(0.93 0.05 155);
  --primary-300: oklch(0.82 0.11 155);
  --primary-400: oklch(0.73 0.14 155);
  --primary-500: oklch(0.66 0.16 155);
  --primary-600: oklch(0.55 0.17 155);
  --primary-700: oklch(0.45 0.15 155);
  --accent-purple: oklch(0.68 0.12 185);
}

:root[data-accent="amber"] {
  --primary-50: oklch(0.98 0.024 75);
  --primary-100: oklch(0.94 0.06 75);
  --primary-300: oklch(0.84 0.12 75);
  --primary-400: oklch(0.76 0.15 75);
  --primary-500: oklch(0.69 0.17 75);
  --primary-600: oklch(0.58 0.18 75);
  --primary-700: oklch(0.48 0.16 75);
  --accent-purple: oklch(0.66 0.14 55);
}

[data-theme="dark"][data-accent="blue"] {
  --accent-soft: oklch(0.3 0.12 245 / 0.18);
  --accent-soft-strong: oklch(0.3 0.12 245 / 0.3);
  --shadow-focus: 0 0 0 3px oklch(0.62 0.18 245 / 0.3);
  --shadow-glow: 0 0 32px -4px oklch(0.62 0.18 245 / 0.5);
}

[data-theme="dark"][data-accent="green"] {
  --accent-soft: oklch(0.3 0.11 155 / 0.18);
  --accent-soft-strong: oklch(0.3 0.11 155 / 0.3);
  --shadow-focus: 0 0 0 3px oklch(0.66 0.16 155 / 0.3);
  --shadow-glow: 0 0 32px -4px oklch(0.66 0.16 155 / 0.5);
}

[data-theme="dark"][data-accent="amber"] {
  --accent-soft: oklch(0.32 0.1 75 / 0.2);
  --accent-soft-strong: oklch(0.32 0.1 75 / 0.34);
  --shadow-focus: 0 0 0 3px oklch(0.69 0.17 75 / 0.3);
  --shadow-glow: 0 0 32px -4px oklch(0.69 0.17 75 / 0.5);
}

/* ========== Reset ========== */
* { box-sizing: border-box; margin: 0; padding: 0; }
*::before, *::after { box-sizing: border-box; }
html, body { height: 100%; width: 100%; max-width: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01", "ss03";
  text-rendering: optimizeLegibility;
  overflow: hidden;
  transition: background-color var(--t-slow) var(--ease-out), color var(--t-slow) var(--ease-out);
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; outline: none; border: none; background: none; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
svg { flex-shrink: 0; }
img { display: block; max-width: 100%; }

::selection { background: var(--accent-soft-strong); color: var(--fg); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--neutral-300); border-radius: var(--r-full); border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--neutral-400); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--neutral-700); border-color: var(--bg); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: var(--neutral-600); }

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ============================================================
   Pages & Layout
   ============================================================ */
.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  background: var(--bg);
  pointer-events: none;
  transition: opacity 300ms var(--ease-out);
}
.boot-logo {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-xl);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-4);
}
.boot-name { font-size: var(--text-lg); font-weight: var(--weight-bold); letter-spacing: 0; }
.boot-progress {
  width: 120px;
  height: 3px;
  overflow: hidden;
  border-radius: var(--r-full);
  background: var(--bg-muted);
}
.boot-bar {
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  animation: bootProgress 900ms var(--ease-out) infinite;
}
@keyframes bootProgress {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(260%); }
}
.page { display: none; height: 100vh; width: 100vw; }
.page.active { display: block; }

/* ============================================================
   Login Page v2
   ============================================================ */
#page-login { position: relative; overflow: hidden; }

.login-bg {
  position: absolute; inset: 0; z-index: 0;
  background:
    radial-gradient(at 15% 20%, oklch(0.94 0.06 280 / 0.4) 0%, transparent 50%),
    radial-gradient(at 85% 80%, oklch(0.95 0.08 305 / 0.35) 0%, transparent 50%),
    radial-gradient(at 50% 100%, oklch(0.96 0.05 75 / 0.2) 0%, transparent 50%),
    var(--bg);
}
[data-theme="dark"] .login-bg {
  background:
    radial-gradient(at 15% 20%, oklch(0.3 0.15 280 / 0.3) 0%, transparent 50%),
    radial-gradient(at 85% 80%, oklch(0.3 0.18 305 / 0.25) 0%, transparent 50%),
    radial-gradient(at 50% 100%, oklch(0.3 0.12 75 / 0.2) 0%, transparent 50%),
    var(--bg);
}

.orb {
  position: absolute; border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  pointer-events: none;
  will-change: transform;
}
.orb-1 {
  width: 480px; height: 480px;
  background: radial-gradient(circle, oklch(0.7 0.2 280 / 0.6), transparent);
  top: -120px; left: -120px;
  animation: float 24s ease-in-out infinite;
}
.orb-2 {
  width: 420px; height: 420px;
  background: radial-gradient(circle, oklch(0.7 0.22 305 / 0.55), transparent);
  bottom: -100px; right: -100px;
  animation: float 30s ease-in-out infinite reverse;
}
.orb-3 {
  width: 360px; height: 360px;
  background: radial-gradient(circle, oklch(0.75 0.15 220 / 0.5), transparent);
  top: 40%; left: 60%;
  animation: float 22s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -40px) scale(1.08); }
  66% { transform: translate(-30px, 30px) scale(0.92); }
}

.grid-overlay {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(oklch(0.5 0.05 280 / 0.06) 1px, transparent 1px),
    linear-gradient(90deg, oklch(0.5 0.05 280 / 0.06) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 20%, transparent 70%);
}

.login-container {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 1fr 1fr;
  height: 100vh; max-width: 1440px;
  margin: 0 auto; padding: 0 var(--s-12);
  gap: var(--s-16);
}

.login-left {
  display: flex; flex-direction: column;
  justify-content: space-between;
  padding: var(--s-10) 0;
}

.brand { display: flex; align-items: center; gap: var(--s-3); }
.brand-logo { display: flex; align-items: center; gap: var(--s-2); }
.brand-name { font-size: 19px; font-weight: var(--weight-bold); letter-spacing: -0.02em; }
.brand-tag { font-size: var(--text-xs); color: var(--fg-secondary); padding: 2px 8px; background: var(--bg-subtle); border-radius: var(--r-full); font-weight: var(--weight-medium); }

.login-hero { max-width: 520px; }
.login-hero h1 {
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: var(--weight-bold);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: var(--s-6);
}
.text-gradient { background: linear-gradient(135deg, var(--primary-600), var(--accent-purple)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-hero p { font-size: var(--text-lg); color: var(--fg-secondary); line-height: var(--leading-relaxed); margin-bottom: var(--s-8); }

.feature-pills { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.pill {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  box-shadow: var(--shadow-1);
  transition: all var(--t-fast) var(--ease-out);
}
.pill:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); border-color: var(--border-strong); }
.dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.dot-success { background: var(--accent-emerald); }
.dot-info { background: var(--info); }
.dot-warn { background: var(--warning); }
.dot-accent { background: var(--accent); }
.dot-purple { background: var(--accent-purple); }

.login-footer { font-size: var(--text-xs); color: var(--fg-tertiary); display: flex; align-items: center; gap: var(--s-2); }
/* P0-2 Fix: 删 ::before 双 lock icon（HTML 已有 inline SVG） */

.login-right { display: flex; align-items: center; justify-content: center; padding: var(--s-10) 0; }
.login-card {
  width: 100%; max-width: 420px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  padding: var(--s-8);
  box-shadow: var(--shadow-5);
  /* P1-20: 去掉 backdrop-filter（背景 orb 已 blur，避免双层模糊） */
}

.card-tabs {
  display: flex; gap: 2px; padding: 4px;
  background: var(--bg-subtle);
  border-radius: var(--r-md);
  margin-bottom: var(--s-6);
}
.tab {
  flex: 1; padding: 8px 12px;
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  color: var(--fg-secondary);
  border-radius: var(--r-sm);
  transition: all var(--t-fast) var(--ease-out);
}
.tab.active { background: var(--bg-elevated); color: var(--fg); box-shadow: var(--shadow-1); }
.tab:hover:not(.active) { color: var(--fg); }

.login-card h2 { font-family: var(--font-display); font-size: 28px; font-weight: var(--weight-bold); margin-bottom: var(--s-1); letter-spacing: -0.02em; }
.card-sub { font-size: var(--text-sm); color: var(--fg-secondary); margin-bottom: var(--s-6); }
.auth-register-fields[hidden] { display: none; }

.form-group { margin-bottom: var(--s-4); }
.form-group label, .label-row label { display: block; font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--fg); margin-bottom: 6px; }
.label-row { display: flex; align-items: center; justify-content: space-between; }
.link { font-size: var(--text-sm); color: var(--accent); cursor: pointer; font-weight: var(--weight-medium); }
button.link {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--accent);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.link:hover { text-decoration: underline; }
.input-wrap {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: all var(--t-fast) var(--ease-out);
}
.input-wrap:hover { border-color: var(--border-strong); }
.input-wrap:focus-within { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.input-icon { color: var(--fg-tertiary); flex-shrink: 0; }
.input-wrap input { flex: 1; font-size: var(--text-md); color: var(--fg); }
.input-wrap input::placeholder { color: var(--fg-muted); }

.form-row { margin-bottom: var(--s-5); }
.checkbox { display: flex; align-items: center; gap: 6px; font-size: var(--text-sm); color: var(--fg-secondary); cursor: pointer; user-select: none; }
.checkbox input { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px;
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  border-radius: var(--r-md);
  transition: all var(--t-fast) var(--ease-out);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  text-align: left;
}
.btn:focus-visible { box-shadow: var(--shadow-focus); outline: none; }
.btn-primary { background: var(--accent); color: var(--fg-on-accent); box-shadow: 0 1px 2px oklch(0 0 0 / 0.06), inset 0 1px 0 oklch(1 0 0 / 0.1); }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 6px 16px -6px oklch(0.5 0.14 245 / 0.26), 0 2px 4px oklch(0 0 0 / 0.06); }
.btn-primary:active { transform: translateY(0); box-shadow: 0 1px 2px oklch(0 0 0 / 0.06); }
.btn-primary.neutral { background: var(--fg); color: var(--fg-inverse); box-shadow: 0 1px 2px oklch(0 0 0 / 0.06); }
.btn-primary.neutral:hover { background: var(--neutral-800); box-shadow: var(--shadow-3); }
.btn-ghost { background: var(--bg-elevated); color: var(--fg); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-subtle); border-color: var(--border-strong); }
.btn-soft { background: var(--bg-subtle); color: var(--fg); }
.btn-soft:hover { background: var(--bg-muted); }
.btn-block { width: 100%; padding: 11px 16px; font-size: var(--text-md); }
.btn-sm { padding: 5px 10px; font-size: var(--text-sm); }
.btn-icon { width: 28px; height: 28px; padding: 0; }
.btn-lg { padding: 12px 20px; font-size: var(--text-md); }

.divider { display: flex; align-items: center; gap: var(--s-3); margin: var(--s-5) 0; color: var(--fg-tertiary); font-size: var(--text-xs); font-weight: var(--weight-medium); }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.sso-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-2); }
.sso-btn {
  padding: 12px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  transition: all var(--t-fast) var(--ease-out);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.sso-btn:hover { background: var(--bg-subtle); border-color: var(--accent); transform: translateY(-1px); }
/* R5: 移除 .sso-btn::before 死代码（HTML 已改用 SVG） */

/* ============================================================
   App Shell
   ============================================================ */
.app-shell {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  width: 100%;
  max-width: 100vw;
  min-width: 0;
  overflow: hidden;
  background: var(--bg);
}

/* ============================================================
   Sidebar v2
   ============================================================ */
.sidebar {
  background: var(--bg-elevated);
  color: var(--fg);
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  position: relative;
  z-index: 10;
  width: var(--side-w);
  min-width: var(--side-w);
  overflow: hidden;
  transition: width var(--t-slow) var(--ease-emph), box-shadow var(--t-mid) var(--ease-out);
}
.sidebar-backdrop { display: none; }
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-4) var(--s-4) var(--s-3);
}
.sidebar-head .icon-btn { color: var(--fg-tertiary); }
.sidebar-head .icon-btn:hover { color: var(--fg); background: var(--bg-subtle); }

.sidebar-search {
  display: flex; align-items: center; gap: 8px;
  margin: 0 var(--s-3) var(--s-2);
  padding: 7px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--text-sm); color: var(--fg-tertiary);
  transition: all var(--t-fast) var(--ease-out);
  cursor: pointer;
  width: calc(100% - var(--s-6));
}
.sidebar-search:hover { background: var(--bg-elevated); border-color: var(--border-strong); color: var(--fg-secondary); }
.sidebar-search kbd { margin-left: auto; padding: 1px 5px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r-xs); font-size: 10px; color: var(--fg-tertiary); font-family: var(--font-mono); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--s-2) var(--s-2); }
.nav-section { margin-bottom: var(--s-4); }
.nav-label { padding: var(--s-2) var(--s-3) 6px; font-size: 10px; font-weight: var(--weight-semibold); color: var(--fg-tertiary); text-transform: uppercase; letter-spacing: 0.08em; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: var(--r-md);
  font-size: var(--text-md); color: var(--fg-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-out);
  position: relative;
  font-weight: var(--weight-medium);
}
.nav-item:hover { background: var(--bg-subtle); color: var(--fg); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item.active::before {
  content: ''; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 16px; background: var(--accent); border-radius: 0 var(--r-full) var(--r-full) 0;
}
.nav-item.sub { padding-left: 28px; font-size: var(--text-sm); color: var(--fg-tertiary); font-weight: var(--weight-normal); }
.nav-item.sub:hover { color: var(--fg); }
.nav-item.sub.active { color: var(--accent); background: transparent; font-weight: var(--weight-medium); }
.nav-item.sub.active::before { display: none; }
.nav-item.add { color: var(--fg-tertiary); font-style: normal; border: 1px dashed transparent; }
.nav-item.add:hover { color: var(--accent); border-color: var(--border); }
.nav-icon { width: 16px; height: 16px; }
.nav-badge { margin-left: auto; padding: 1px 6px; background: var(--danger); color: white; border-radius: var(--r-full); font-size: 10px; font-weight: var(--weight-semibold); }
.nav-badge-mini { margin-left: auto; padding: 0 5px; background: var(--bg-muted); color: var(--fg-secondary); border-radius: var(--r-full); font-size: 10px; font-weight: var(--weight-semibold); }
.nav-dot { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 6px; height: 6px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 0 3px var(--accent-soft); }
.proj-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex-shrink: 0; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  color: var(--fg-secondary);
  transition: all var(--t-fast) var(--ease-out);
  position: relative;
}
.icon-btn:hover { background: var(--bg-subtle); color: var(--fg); }
.icon-btn.ghost { background: transparent; }
.icon-btn.ghost:hover { background: var(--bg-subtle); }
.icon-btn.lg { width: 32px; height: 32px; }
.icon-btn:focus-visible { box-shadow: var(--shadow-focus); outline: none; }
.dot-indicator {
  position: absolute; top: 4px; right: 4px;
  width: 6px; height: 6px;
  background: var(--danger);
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--bg-elevated);
}

.sidebar-foot { padding: var(--s-3); border-top: 1px solid var(--border-subtle); }
.user-card { display: flex; align-items: center; gap: 8px; padding: 4px; border-radius: var(--r-md); transition: all var(--t-fast) var(--ease-out); }
.user-profile-link {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  padding: 4px;
  border: 0;
  background: transparent;
  border-radius: var(--r-sm);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.user-profile-link:hover { background: var(--bg-subtle); }
.user-profile-link:focus-visible { box-shadow: var(--shadow-focus); outline: none; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-status { font-size: var(--text-xs); color: var(--fg-tertiary); display: flex; align-items: center; gap: 4px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--fg-muted); flex-shrink: 0; }
.status-dot.online { background: var(--accent-emerald); box-shadow: 0 0 0 2px var(--accent-emerald-soft, oklch(0.95 0.04 155)); animation: pulse 2.4s var(--ease-in-out) infinite; }
.status-dot.away { background: var(--warning); }
.status-dot.busy { background: var(--danger); }
.status-dot.offline { background: var(--fg-muted); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 2px oklch(0.95 0.04 155); }
  50% { box-shadow: 0 0 0 4px oklch(0.95 0.04 155 / 0.4); }
}

@media (min-width: 769px) {
  .sidebar:hover,
  .sidebar:focus-within,
  .sidebar.expanded {
    width: var(--side-expanded-w);
    min-width: var(--side-expanded-w);
    z-index: 60;
    box-shadow: var(--shadow-5);
  }

  .sidebar:hover ~ .main,
  .sidebar:focus-within ~ .main,
  .sidebar.expanded ~ .main {
    margin-left: 0;
    width: 100%;
  }

  .sidebar:not(.expanded):not(:hover):not(:focus-within) .brand-name,
  .sidebar:not(.expanded):not(:hover):not(:focus-within) .sidebar-head .icon-btn,
  .sidebar:not(.expanded):not(:hover):not(:focus-within) .sidebar-search span,
  .sidebar:not(.expanded):not(:hover):not(:focus-within) .sidebar-search kbd,
  .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-label,
  .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-item > span:not(.nav-dot):not(.proj-dot):not(.nav-badge):not(.nav-badge-mini),
  .sidebar:not(.expanded):not(:hover):not(:focus-within) .user-info,
  .sidebar:not(.expanded):not(:hover):not(:focus-within) .user-card .icon-btn {
    opacity: 0;
    visibility: hidden;
    max-width: 0;
    pointer-events: none;
  }

  .sidebar:not(.expanded):not(:hover):not(:focus-within) .sidebar-head {
    justify-content: center;
    padding-left: var(--s-3);
    padding-right: var(--s-3);
  }

  .sidebar:not(.expanded):not(:hover):not(:focus-within) .sidebar-search {
    width: 40px;
    height: 40px;
    margin: 0 auto var(--s-3);
    padding: 0;
    justify-content: center;
    gap: 0;
  }

  .sidebar:not(.expanded):not(:hover):not(:focus-within) .sidebar-nav {
    padding: var(--s-2) var(--s-3);
  }

  .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-label {
    height: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
  }

  .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-section {
    margin-bottom: var(--s-3);
  }

  .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-item {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
    gap: 0;
  }

  .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-item.sub {
    padding-left: 0;
  }

  .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-item.active::before {
    left: -12px;
  }

  .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-badge,
  .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-badge-mini {
    position: absolute;
    top: 5px;
    right: 4px;
    width: 8px;
    height: 8px;
    min-width: 0;
    padding: 0;
    color: transparent;
    overflow: hidden;
    border: 2px solid var(--bg-elevated);
  }

  .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-dot {
    right: 6px;
    top: 8px;
    transform: none;
  }

  .sidebar:not(.expanded):not(:hover):not(:focus-within) .sidebar-foot {
    padding: var(--s-3) var(--s-2);
  }

  .sidebar:not(.expanded):not(:hover):not(:focus-within) .user-card {
    justify-content: center;
    padding: var(--s-2);
  }

  .sidebar.force-collapsed,
  .sidebar.force-collapsed:hover,
  .sidebar.force-collapsed:focus-within {
    width: var(--side-w);
    min-width: var(--side-w);
    z-index: 10;
    box-shadow: none;
  }

  .sidebar.force-collapsed .brand-name,
  .sidebar.force-collapsed .sidebar-head .icon-btn,
  .sidebar.force-collapsed .sidebar-search span,
  .sidebar.force-collapsed .sidebar-search kbd,
  .sidebar.force-collapsed .nav-label,
  .sidebar.force-collapsed .nav-item > span:not(.nav-dot):not(.proj-dot):not(.nav-badge):not(.nav-badge-mini),
  .sidebar.force-collapsed .user-info,
  .sidebar.force-collapsed .user-card .icon-btn {
    opacity: 0;
    visibility: hidden;
    max-width: 0;
    pointer-events: none;
  }

  .sidebar.force-collapsed .sidebar-head {
    justify-content: center;
    padding-left: var(--s-3);
    padding-right: var(--s-3);
  }

  .sidebar.force-collapsed .sidebar-search {
    width: 40px;
    height: 40px;
    margin: 0 auto var(--s-3);
    padding: 0;
    justify-content: center;
    gap: 0;
  }

  .sidebar.force-collapsed .sidebar-nav {
    padding: var(--s-2) var(--s-3);
  }

  .sidebar.force-collapsed .nav-label {
    height: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
  }

  .sidebar.force-collapsed .nav-section {
    margin-bottom: var(--s-3);
  }

  .sidebar.force-collapsed .nav-item {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
    gap: 0;
  }

  .sidebar.force-collapsed .nav-item.sub {
    padding-left: 0;
  }

  .sidebar.force-collapsed .nav-item.active::before {
    left: -12px;
  }

  .sidebar.force-collapsed .nav-badge,
  .sidebar.force-collapsed .nav-badge-mini {
    position: absolute;
    top: 5px;
    right: 4px;
    width: 8px;
    height: 8px;
    min-width: 0;
    padding: 0;
    color: transparent;
    overflow: hidden;
    border: 2px solid var(--bg-elevated);
  }

  .sidebar.force-collapsed .nav-dot {
    right: 6px;
    top: 8px;
    transform: none;
  }

  .sidebar.force-collapsed .sidebar-foot {
    padding: var(--s-3) var(--s-2);
  }

  .sidebar.force-collapsed .user-card {
    justify-content: center;
    padding: var(--s-2);
  }
}

/* ============================================================
   Avatar
   ============================================================ */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: var(--weight-semibold);
  color: white;
  background: linear-gradient(135deg, var(--a1, var(--primary-500)), var(--a2, var(--accent-purple)));
  border-radius: var(--r-full);
  flex-shrink: 0;
  position: relative;
  letter-spacing: -0.02em;
  user-select: none;
}
.avatar-xs { width: 20px; height: 20px; font-size: 9px; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-md { width: 36px; height: 36px; font-size: 13px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar-xl { width: 64px; height: 64px; font-size: 20px; }
.avatar.online::after {
  content: ''; position: absolute; bottom: 0; right: 0;
  width: 10px; height: 10px;
  background: var(--accent-emerald);
  border: 2px solid var(--bg-elevated);
  border-radius: 50%;
}
.avatar.group { background: linear-gradient(135deg, var(--a1), var(--a2)); }
.avatar.agent-avatar { font-size: 13px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--bg-elevated); margin-left: -8px; box-shadow: var(--shadow-1); }
.avatar-stack .avatar:first-child { margin-left: 0; }
.avatar-stack .avatar-more {
  background: var(--bg-muted);
  color: var(--fg-secondary);
  font-size: 9px;
  font-weight: var(--weight-semibold);
}

/* ============================================================
   Main & Topbar
   ============================================================ */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  overflow: hidden;
  background: var(--bg);
  transition:
    margin-left var(--t-slow) var(--ease-emph),
    width var(--t-slow) var(--ease-emph);
}

.topbar {
  display: flex; align-items: center; gap: var(--s-4);
  height: var(--topbar-h);
  padding: 0 var(--s-6);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  position: relative;
  z-index: 5;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: var(--s-2); min-width: 0; }
.topbar-left, .topbar-right { flex-shrink: 0; }
.topbar-center { flex: 1 1 auto; max-width: 480px; min-width: 0; margin: 0 auto; }
.breadcrumb { display: flex; align-items: center; gap: 4px; font-size: var(--text-md); color: var(--fg-tertiary); }
.topbar-workspace-trigger { flex: 0 0 auto; }
.crumb-current { font-weight: var(--weight-semibold); color: var(--fg); }
.mobile-page-title { display: none; font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  background: var(--bg-subtle);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: var(--text-sm); color: var(--fg-tertiary);
  transition: all var(--t-fast) var(--ease-out);
  cursor: pointer;
  width: 100%;
  min-width: 0;
}
.search-box:hover { background: var(--bg-elevated); border-color: var(--border); }
.search-box input { flex: 1 1 auto; min-width: 0; font-size: var(--text-sm); color: var(--fg); pointer-events: none; text-overflow: ellipsis; }
.search-box kbd { padding: 1px 5px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r-xs); font-size: 10px; color: var(--fg-tertiary); font-family: var(--font-mono); }
.topbar-divider { width: 1px; height: 20px; background: var(--border); margin: 0 var(--s-1); }

/* 主题切换按钮 */
.theme-toggle {
  position: relative;
  width: 36px; height: 20px;
  background: var(--bg-muted);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-out);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle .theme-icon-light,
.theme-toggle .theme-icon-dark {
  width: 14px; height: 14px;
  color: var(--fg-secondary);
  position: absolute;
  transition: opacity var(--t-fast) var(--ease-out), transform var(--t-mid) var(--ease-out);
}
.theme-toggle .theme-icon-dark { opacity: 0; transform: rotate(-90deg) scale(0.6); }
[data-theme="dark"] .theme-toggle .theme-icon-light { opacity: 0; transform: rotate(90deg) scale(0.6); }
[data-theme="dark"] .theme-toggle .theme-icon-dark { opacity: 1; transform: rotate(0) scale(1); }
/* P0-1 Fix: 删 ::after 双 sun/moon icon（HTML 已有 inline SVG 替代） */

/* ============================================================
   Views
   ============================================================ */
.view { display: none; flex: 1 1 0; min-height: 0; overflow: hidden; }
.view.active { display: flex; animation: viewIn var(--t-page) var(--ease-out); }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.view-scroll { flex: 1; overflow-y: auto; padding: var(--s-6) var(--s-8); }

/* ============================================================
   Page Head
   ============================================================ */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-6); }
.page-title { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: var(--weight-bold); letter-spacing: -0.02em; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.page-title .lucide { color: var(--warning); width: 0.85em; height: 0.85em; }
.page-sub { font-size: var(--text-md); color: var(--fg-secondary); }
.head-actions { display: flex; align-items: center; gap: var(--s-2); }
.seg-control { display: flex; padding: 3px; background: var(--bg-subtle); border-radius: var(--r-md); border: 1px solid var(--border); }
.seg { padding: 6px 12px; font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--fg-secondary); border-radius: var(--r-sm); transition: all var(--t-fast) var(--ease-out); }
.seg.active { background: var(--bg-elevated); color: var(--fg); box-shadow: var(--shadow-1); }
.seg:hover:not(.active) { color: var(--fg); }
.seg-control.small { padding: 2px; }
.seg-control.small .seg { padding: 4px 8px; }

/* ============================================================
   Dashboard Grid
   ============================================================ */
.dashboard-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--s-4); min-width: 0; }
.ai-card {
  grid-column: span 8;
  position: relative; overflow: hidden;
  background:
    linear-gradient(135deg, var(--bg-elevated) 0%, oklch(0.988 0.004 255) 70%, oklch(0.974 0.014 235) 100%);
  border: 1px solid var(--border);
}
[data-theme="dark"] .ai-card {
  background:
    linear-gradient(135deg, var(--bg-elevated) 0%, oklch(0.17 0.018 270) 62%, oklch(0.22 0.05 260) 100%);
}
.ai-glow {
  position: absolute; top: -80px; right: -80px;
  width: 220px; height: 220px;
  background: radial-gradient(circle, oklch(0.68 0.12 245 / 0.08), transparent 68%);
  filter: blur(52px);
  pointer-events: none;
  opacity: 0.55;
}
@keyframes glowPulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.1); opacity: 0.8; }
}
.ai-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}
.ai-avatar {
  width: 34px; height: 34px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  box-shadow: none;
}
.ai-name { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.ai-status { font-size: var(--text-xs); color: var(--fg-tertiary); display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.ai-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--s-3); position: relative; }
.ai-chip {
  padding: 5px 9px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  transition: all var(--t-fast) var(--ease-out);
  font-weight: var(--weight-medium);
}
.ai-chip:nth-child(n+4) { display: none; }
.ai-chip:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.dashboard-focus {
  position: relative;
  margin: 0 0 var(--s-3);
  padding: 0 0 var(--s-3);
  border-bottom: 1px solid var(--border-subtle);
}
.dashboard-focus-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: 6px;
}
.dashboard-focus-head strong { display: block; font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--fg); }
.focus-eyebrow { display: block; font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--fg-tertiary); margin-bottom: 2px; }
.focus-open {
  flex-shrink: 0;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--bg-elevated);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  transition: all var(--t-fast) var(--ease-out);
}
.focus-open:hover { border-color: var(--accent); background: var(--accent-soft); }
.dashboard-focus-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px var(--s-3);
}
.dashboard-focus-item {
  min-width: 0;
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-radius: var(--r-sm);
  text-align: left;
  color: var(--fg);
  transition: background var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
.dashboard-focus-item:hover { background: var(--bg-subtle); transform: translateX(2px); }
.dashboard-focus-item:focus-visible, .focus-open:focus-visible, .dashboard-focus-empty:focus-visible { box-shadow: var(--shadow-focus); outline: none; }
.focus-kind {
  min-width: 44px;
  max-width: 62px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dashboard-focus-item.danger .focus-kind { background: oklch(0.95 0.04 25); border-color: oklch(0.9 0.07 25); color: var(--danger-strong); }
.dashboard-focus-item.warning .focus-kind { background: oklch(0.96 0.05 75); border-color: oklch(0.9 0.08 75); color: var(--warning-strong); }
.dashboard-focus-item.accent .focus-kind { background: var(--accent-soft); border-color: oklch(0.86 0.08 265); color: var(--accent); }
.dashboard-focus-item.info .focus-kind { background: oklch(0.95 0.04 245); border-color: oklch(0.88 0.07 245); color: var(--info); }
.focus-main { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.focus-main b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-sm);
  line-height: 1.35;
  font-weight: var(--weight-semibold);
}
.focus-main span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  line-height: 1.3;
}
.focus-go { color: var(--fg-tertiary); font-size: var(--text-lg); line-height: 1; }
.dashboard-focus-empty {
  width: 100%;
  padding: 9px 4px;
  border-radius: var(--r-sm);
  color: var(--fg-secondary);
  text-align: left;
  font-size: var(--text-sm);
  transition: background var(--t-fast) var(--ease-out);
}
.dashboard-focus-empty:hover { background: var(--bg-subtle); color: var(--fg); }
.ai-input {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 4px 4px var(--s-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  position: relative;
  transition: all var(--t-fast) var(--ease-out);
  box-shadow: none;
}
.ai-input:focus-within { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.ai-input input { flex: 1; font-size: var(--text-md); padding: 8px 0; color: var(--fg); }
.ai-input input::placeholder { color: var(--fg-muted); }
.ai-input-suffix { display: flex; gap: 4px; align-items: center; padding-right: 4px; }

.stat-card {
  grid-column: span 3;
  padding: var(--s-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: all var(--t-mid) var(--ease-out);
  min-width: 0;
  cursor: pointer;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-3); border-color: var(--border-strong); }
.stat-icon { width: 36px; height: 36px; background: var(--bg); color: var(--c); border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; margin-bottom: var(--s-3); }
.stat-label { font-size: var(--text-sm); color: var(--fg-secondary); margin-bottom: 4px; }
.stat-value { font-size: var(--text-2xl); font-weight: var(--weight-bold); letter-spacing: -0.02em; display: flex; align-items: baseline; gap: 6px; }
.stat-unit { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--fg-secondary); }
.stat-trend { font-size: var(--text-xs); font-weight: var(--weight-semibold); padding: 2px 6px; background: var(--bg-subtle); color: var(--fg-secondary); border-radius: var(--r-full); display: inline-flex; align-items: center; gap: 2px; }
.stat-trend.up { background: oklch(0.95 0.04 155); color: var(--success-strong); }
.stat-trend.down { background: oklch(0.95 0.04 25); color: var(--danger-strong); }
.stat-bar { height: 4px; background: var(--bg-subtle); border-radius: var(--r-full); margin-top: var(--s-3); overflow: hidden; }
.stat-bar-fill { height: 100%; background: var(--c); border-radius: var(--r-full); transition: width 1s var(--ease-out); }

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  transition: border-color var(--t-fast) var(--ease-out);
}
.card:hover { border-color: var(--border-strong); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-4); }
.card-head h3 { font-size: var(--text-md); font-weight: var(--weight-semibold); }

.todo-card { grid-column: span 6; }
.todo-list { display: flex; flex-direction: column; gap: 2px; }
.todo-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  transition: all var(--t-fast) var(--ease-out);
  cursor: pointer;
  border: 1px solid transparent;
}
.todo-item:hover { background: var(--bg-subtle); border-color: var(--border); }
.todo-body { flex: 1; min-width: 0; }
.todo-body.done .todo-title { color: var(--fg-tertiary); text-decoration: line-through; }
.todo-title { font-size: var(--text-md); font-weight: var(--weight-medium); margin-bottom: 4px; }
.todo-meta { display: flex; align-items: center; gap: 8px; font-size: var(--text-xs); color: var(--fg-secondary); }
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 6px;
  font-size: 10px; font-weight: var(--weight-semibold);
  border-radius: var(--r-sm);
  letter-spacing: 0.02em;
}
.badge-red { background: oklch(0.95 0.04 25); color: var(--danger-strong); }
.badge-amber { background: oklch(0.96 0.05 75); color: var(--warning-strong); }
.badge-green { background: oklch(0.95 0.04 155); color: var(--success-strong); }
.badge-blue { background: oklch(0.95 0.04 245); color: var(--info); }
.badge-purple { background: oklch(0.95 0.04 305); color: var(--accent-purple); }
.proj-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 6px 1px 4px;
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  border-radius: var(--r-sm);
  font-size: 10px; font-weight: var(--weight-medium);
}
.proj-tag::before { content: ''; width: 5px; height: 5px; background: var(--c); border-radius: 50%; }
.meta-due { color: var(--fg-tertiary); }

/* Checkbox (real input + visual box) */
.check { position: relative; display: inline-block; width: 18px; height: 18px; flex-shrink: 0; cursor: pointer; }
.check input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.check-box { position: absolute; inset: 0; display: block; border: 1.5px solid var(--border-strong); border-radius: var(--r-sm); background: var(--bg-elevated); transition: all var(--t-fast) var(--ease-out); pointer-events: none; }
.check:hover .check-box { border-color: var(--accent); }
.check input:focus-visible + .check-box { box-shadow: var(--shadow-focus); }
.check input:checked + .check-box { background: var(--accent); border-color: var(--accent); }
.check input:checked + .check-box::after { content: '✓'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: white; font-size: 11px; font-weight: var(--weight-bold); line-height: 1; }
.todo-item:has(input:checked) .todo-title { color: var(--fg-tertiary); text-decoration: line-through; }
.todo-item:has(input:checked) .check-box { background: var(--accent); border-color: var(--accent); }

.project-card { grid-column: span 6; }
.proj-list { display: flex; flex-direction: column; gap: var(--s-3); }
.proj-row { padding: var(--s-3); background: var(--bg-subtle); border-radius: var(--r-md); transition: all var(--t-fast) var(--ease-out); cursor: pointer; }
.proj-row:hover { background: var(--bg-muted); transform: translateX(2px); }
.proj-row-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: var(--text-md); font-weight: var(--weight-medium); }
.proj-name { flex: 1; }
.proj-percent { font-weight: var(--weight-semibold); color: var(--fg-secondary); font-size: var(--text-sm); }
.proj-bar { height: 6px; background: var(--bg-elevated); border-radius: var(--r-full); overflow: hidden; margin-bottom: 6px; }
.proj-bar > div { height: 100%; border-radius: var(--r-full); transition: width 1s var(--ease-out); }
.proj-row-foot { display: flex; gap: 4px; font-size: var(--text-xs); color: var(--fg-tertiary); }

.activity-card { grid-column: span 4; }
.activity-list { display: flex; flex-direction: column; gap: var(--s-3); }
.activity { display: flex; gap: 10px; padding: 6px 4px; border-radius: var(--r-md); transition: background var(--t-fast); }
.activity:hover { background: var(--bg-subtle); }
.activity-body { flex: 1; font-size: var(--text-sm); line-height: var(--leading-snug); color: var(--fg); }
.activity-body b { font-weight: var(--weight-semibold); }
.activity-time { color: var(--fg-tertiary); font-size: var(--text-xs); margin-top: 4px; }
.activity-time em {
  display: inline-flex;
  margin-right: 6px;
  padding: 1px 5px;
  border-radius: var(--r-full);
  background: var(--warning-soft);
  color: var(--warning);
  font-style: normal;
  font-weight: var(--weight-semibold);
}
.runtime-activity { cursor: pointer; }
.runtime-activity.is-actionable {
  background: linear-gradient(90deg, var(--bg-subtle), transparent 72%);
}
.activity-empty {
  padding: 18px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}
.activity-view-all:focus-visible {
  outline: none;
  text-decoration: underline;
}
.activity-center {
  position: fixed;
  inset: 0;
  z-index: 1470;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--t-fast) var(--ease-out), visibility var(--t-fast) var(--ease-out);
}
.activity-center.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.activity-center-backdrop {
  position: absolute;
  inset: 0;
  background: oklch(0.12 0.01 270 / 0.24);
}
.activity-center-panel {
  position: absolute;
  top: var(--s-4);
  right: var(--s-4);
  bottom: var(--s-4);
  width: min(460px, calc(100vw - var(--s-8)));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-5);
  transform: translateX(16px) scale(0.98);
  transition: transform var(--t-fast) var(--ease-out);
}
.activity-center.open .activity-center-panel { transform: translateX(0) scale(1); }
.activity-center-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-4);
  border-bottom: 1px solid var(--border-subtle);
}
.activity-center-head span {
  display: block;
  margin-bottom: 2px;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.activity-center-head h3 {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
}
.activity-center-head p {
  margin-top: 3px;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
}
.activity-center-summary {
  padding: var(--s-3) var(--s-4) 0;
}
.activity-summary-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-2);
}
.activity-summary-card span {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
}
.activity-summary-card strong {
  color: var(--fg);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  line-height: 1.05;
}
.activity-center-filters {
  display: flex;
  gap: 6px;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}
.activity-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--bg-elevated);
  color: var(--fg-secondary);
  white-space: nowrap;
  transition: all var(--t-fast) var(--ease-out);
}
.activity-filter:hover,
.activity-filter:focus-visible {
  outline: none;
  border-color: var(--border-strong);
  background: var(--bg-subtle);
  color: var(--fg);
}
.activity-filter.active {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
}
.activity-filter em {
  font-size: 11px;
  font-style: normal;
  color: inherit;
}
.activity-center-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-3);
}
.activity-center-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: var(--s-3);
  width: 100%;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  text-align: left;
  transition: background var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.activity-center-row:hover,
.activity-center-row:focus-visible {
  outline: none;
  border-color: var(--border);
  background: var(--bg-subtle);
}
.activity-center-row.is-actionable {
  border-color: var(--warning-soft);
  background: color-mix(in oklch, var(--warning-soft) 38%, var(--bg-elevated));
}
.activity-center-row.is-actionable:hover,
.activity-center-row.is-actionable:focus-visible {
  border-color: color-mix(in oklch, var(--warning) 42%, var(--border));
}
.activity-center-main {
  min-width: 0;
}
.activity-center-main strong,
.activity-center-main em,
.activity-center-main span {
  display: block;
}
.activity-center-main strong {
  color: var(--fg);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.activity-center-main em {
  margin-top: 2px;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  font-style: normal;
  line-height: var(--leading-snug);
}
.activity-center-main span {
  margin-top: 4px;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
}
.activity-center-empty {
  display: grid;
  gap: 4px;
  padding: var(--s-5);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  text-align: center;
}
.activity-center-empty strong {
  color: var(--fg);
  font-size: var(--text-sm);
}
.activity-center-empty span {
  font-size: var(--text-xs);
}

.calendar-card { grid-column: span 4; }
.date-badge { font-size: var(--text-xs); color: var(--fg-secondary); padding: 2px 8px; background: var(--bg-subtle); border-radius: var(--r-sm); font-weight: var(--weight-medium); }
.cal-list { display: flex; flex-direction: column; gap: 2px; }
.cal-item {
  display: flex; align-items: stretch; gap: 12px;
  padding: 10px 8px;
  border-radius: var(--r-md);
  transition: all var(--t-fast) var(--ease-out);
  cursor: pointer;
}
.cal-item:hover { background: var(--bg-subtle); }
.cal-item.past,
.cal-item.done { opacity: 0.5; }
.cal-time { display: flex; flex-direction: column; gap: 0; font-size: var(--text-xs); color: var(--fg-tertiary); min-width: 44px; }
.cal-time b { font-size: var(--text-md); color: var(--fg); font-weight: var(--weight-semibold); }
.cal-line { width: 2px; background: var(--c); border-radius: var(--r-full); align-self: stretch; }
.cal-body { flex: 1; min-width: 0; }
.cal-title { font-size: var(--text-md); font-weight: var(--weight-medium); margin-bottom: 2px; }
.cal-meta { font-size: var(--text-xs); color: var(--fg-secondary); }
.runtime-calendar-event { cursor: pointer; }
.cal-item.joined { background: var(--accent-soft); }
.cal-item.done { background: color-mix(in oklab, var(--success-soft) 34%, var(--bg)); }
.cal-action {
  align-self: center;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}
.cal-action:hover { background: var(--accent-soft); color: var(--accent); }
.cal-action:disabled { cursor: default; color: var(--accent); background: var(--accent-soft); }
.calendar-empty {
  padding: 18px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}
.calendar-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: var(--s-4);
  align-items: start;
}
.calendar-main,
.calendar-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.calendar-main {
  min-width: 0;
  padding: var(--s-4);
}
.calendar-side {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  min-width: 0;
}
.calendar-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.calendar-stat-card {
  min-width: 0;
  padding: var(--s-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}
.calendar-stat-card span,
.calendar-stat-card em {
  display: block;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-style: normal;
}
.calendar-stat-card strong {
  display: block;
  margin: 5px 0 3px;
  color: var(--fg);
  font-size: 24px;
  line-height: 1;
}
.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}
.calendar-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.calendar-search {
  flex: 0 1 240px;
  min-width: 190px;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  transition: all var(--t-fast) var(--ease-out);
}
.calendar-search svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.calendar-search input {
  min-width: 0;
  width: 100%;
  color: var(--fg);
  font-size: var(--text-sm);
}
.calendar-search input::placeholder { color: var(--fg-muted); }
.calendar-search:focus-within {
  border-color: var(--accent);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-focus);
}
.calendar-filter {
  padding: 6px 10px;
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.calendar-filter:hover,
.calendar-filter.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.calendar-week-board {
  display: grid;
  grid-template-columns: repeat(7, minmax(128px, 1fr));
  gap: var(--s-2);
  min-height: 430px;
  overflow-x: auto;
}
.calendar-day-col {
  min-width: 128px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg);
  overflow: hidden;
}
.calendar-day-col.today {
  border-color: var(--accent-soft-strong);
  box-shadow: inset 0 0 0 1px var(--accent-soft);
}
.calendar-day-head {
  padding: 10px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
}
.calendar-day-head span,
.calendar-day-head strong {
  display: block;
}
.calendar-day-head span {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
}
.calendar-day-head strong {
  margin-top: 2px;
  color: var(--fg);
  font-size: var(--text-sm);
}
.calendar-day-stack {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 340px;
  padding: 8px;
}
.calendar-event-chip {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 8px;
  border-left: 3px solid var(--c);
  border-radius: var(--r-sm);
  background: color-mix(in oklab, var(--c) 8%, var(--bg-elevated));
  color: var(--fg);
  text-align: left;
  transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.calendar-event-chip:hover,
.calendar-event-chip:focus-visible {
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
  outline: none;
}
.calendar-event-chip span,
.calendar-event-chip em {
  color: var(--fg-tertiary);
  font-size: 10px;
  font-style: normal;
}
.calendar-event-chip strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-sm);
}
.calendar-event-chip.cancelled {
  opacity: .56;
  text-decoration: line-through;
}
.calendar-event-chip.done {
  border-left-color: var(--success);
  background: color-mix(in oklab, var(--success-soft) 38%, var(--bg-elevated));
  opacity: .72;
}
.calendar-day-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px dashed var(--border-subtle);
  border-radius: var(--r-sm);
  color: var(--fg-muted);
  font-size: var(--text-xs);
  background: color-mix(in oklab, var(--bg-subtle) 42%, transparent);
}
.calendar-panel {
  padding: var(--s-3);
}
.calendar-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-3);
}
.calendar-panel-head h3 {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}
.calendar-detail-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg);
}
.calendar-detail-mark {
  height: 3px;
  background: var(--c);
}
.calendar-detail-head {
  display: flex;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3);
}
.calendar-detail-head span {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
}
.calendar-detail-head h3 {
  margin-top: 2px;
  font-size: var(--text-lg);
  line-height: var(--leading-snug);
}
.calendar-detail-head strong {
  flex-shrink: 0;
  align-self: flex-start;
  padding: 3px 8px;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--text-xs);
}
.calendar-detail-card.done .calendar-detail-head strong {
  background: var(--success-soft);
  color: var(--success-strong);
}
.calendar-detail-card.cancelled .calendar-detail-head strong {
  background: var(--danger-soft);
  color: var(--danger-strong);
}
.calendar-detail-grid {
  display: grid;
  gap: 8px;
  padding: 0 var(--s-3) var(--s-3);
}
.calendar-detail-grid div {
  padding: 8px;
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
}
.calendar-detail-grid span,
.calendar-detail-grid strong {
  display: block;
}
.calendar-detail-grid span {
  color: var(--fg-tertiary);
  font-size: 10px;
}
.calendar-detail-grid strong {
  margin-top: 3px;
  color: var(--fg);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}
.calendar-detail-grid .calendar-task-row {
  border: 1px solid color-mix(in oklab, var(--c) 26%, var(--border-subtle));
  background: color-mix(in oklab, var(--c) 7%, var(--bg-subtle));
}
.calendar-detail-grid .calendar-link-row {
  border: 1px solid color-mix(in oklab, var(--accent) 24%, var(--border-subtle));
  background: color-mix(in oklab, var(--accent-soft) 48%, var(--bg-subtle));
}
.calendar-detail-grid .calendar-source-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px 10px;
  border: 1px solid color-mix(in oklab, var(--success) 24%, var(--border-subtle));
  background: color-mix(in oklab, var(--success-soft) 34%, var(--bg-subtle));
}
.calendar-source-row span {
  grid-column: 1 / -1;
}
.calendar-source-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.calendar-source-row .btn {
  grid-column: 2;
  grid-row: 2;
  align-self: center;
  white-space: nowrap;
}
.calendar-link-row strong {
  overflow: hidden;
  color: var(--accent);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.calendar-detail-grid .calendar-join-row {
  border: 1px solid color-mix(in oklab, var(--success) 28%, var(--border-subtle));
  background: color-mix(in oklab, var(--success-soft) 42%, var(--bg-subtle));
}
.calendar-join-row strong {
  color: var(--success-strong);
}
.calendar-task-row strong {
  color: var(--fg);
}
.calendar-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: var(--s-3);
  border-top: 1px solid var(--border-subtle);
}
.calendar-message-share-panel {
  margin: 0 var(--s-3) var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: color-mix(in oklab, var(--bg-elevated) 72%, var(--bg-subtle));
}
.calendar-message-share-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}
.calendar-message-share-head strong {
  color: var(--fg);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.calendar-message-share-head span {
  overflow: hidden;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.calendar-message-share-grid {
  display: grid;
  grid-template-columns: minmax(120px, .7fr) minmax(0, 1.3fr);
  gap: var(--s-3);
}
.calendar-message-share-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.calendar-message-share-grid select,
.calendar-message-share-grid textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: var(--text-sm);
}
.calendar-message-share-grid select {
  height: 34px;
  padding: 0 9px;
}
.calendar-message-share-grid textarea {
  min-height: 72px;
  padding: 9px 10px;
  resize: vertical;
  line-height: var(--leading-relaxed);
}
.calendar-message-share-grid select:focus,
.calendar-message-share-grid textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.calendar-message-share-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--border-subtle);
}
.calendar-message-share-foot span {
  overflow: hidden;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.calendar-agenda-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.calendar-agenda-row {
  display: grid;
  grid-template-columns: 54px 42px 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px;
  border-radius: var(--r-sm);
  text-align: left;
  color: var(--fg-secondary);
}
.calendar-agenda-row:hover,
.calendar-agenda-row:focus-visible {
  background: var(--bg-subtle);
  color: var(--fg);
  outline: none;
}
.calendar-agenda-date,
.calendar-agenda-time,
.calendar-agenda-status,
.calendar-agenda-main em {
  color: var(--fg-tertiary);
  font-size: 10px;
}
.calendar-agenda-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c);
}
.calendar-agenda-main {
  min-width: 0;
}
.calendar-agenda-main strong,
.calendar-agenda-main em {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.calendar-agenda-main strong {
  color: var(--fg);
  font-size: var(--text-sm);
}
.calendar-agenda-row.cancelled,
.calendar-agenda-row.done {
  opacity: .58;
}
.calendar-empty-panel {
  padding: var(--s-4);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  color: var(--fg-tertiary);
  text-align: center;
  font-size: var(--text-sm);
}
.calendar-event-modal { width: min(640px, calc(100vw - 40px)); }
.calendar-event-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
}
.calendar-event-form label {
  display: grid;
  gap: 6px;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
}
.calendar-event-form label.wide {
  grid-column: 1 / -1;
}

/* ============================================================
   Messages v2
   ============================================================ */
.msg-shell {
  position: relative;
  display: grid;
  grid-template-columns: 280px minmax(360px, 1fr);
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.msg-sidebar { display: flex; flex-direction: column; background: var(--bg-elevated); border-right: 1px solid var(--border); min-width: 0; }
.msg-side-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-4); border-bottom: 1px solid var(--border-subtle); }
.msg-side-head h3 { font-size: var(--text-lg); font-weight: var(--weight-bold); letter-spacing: -0.01em; }
.msg-side-actions { display: flex; gap: 2px; }
.msg-side-tabs { display: flex; gap: 2px; padding: var(--s-2) var(--s-3); overflow-x: auto; scrollbar-width: none; }
.msg-side-tabs::-webkit-scrollbar { display: none; }
.msg-tab { flex: 0 0 auto; padding: 6px 10px; font-size: var(--text-sm); color: var(--fg-secondary); border-radius: var(--r-sm); font-weight: var(--weight-medium); transition: all var(--t-fast) var(--ease-out); display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.msg-tab span { color: var(--fg-tertiary); }
.msg-tab.active { background: var(--bg-subtle); color: var(--fg); }
.msg-tab.active span { color: var(--fg-secondary); }
.msg-search {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  margin: 0 var(--s-3) var(--s-2);
  background: var(--bg-subtle);
  border-radius: var(--r-md);
  font-size: var(--text-sm); color: var(--fg-tertiary);
  border: 1px solid transparent;
  transition: all var(--t-fast) var(--ease-out);
}
.msg-search:focus-within { background: var(--bg-elevated); border-color: var(--accent); box-shadow: var(--shadow-focus); }
.msg-search input { flex: 1; font-size: var(--text-sm); color: var(--fg); }
.msg-list { flex: 1; overflow-y: auto; padding: 0 var(--s-2) var(--s-2); }
.msg-conv {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
  padding: 10px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-out);
  position: relative;
  overflow: hidden;
}
.msg-conv:hover { background: var(--bg-subtle); }
.msg-conv.active { background: var(--accent-soft); }
.msg-conv.active .msg-conv-name { color: var(--accent); }
.msg-conv.pinned { border-left: 2px solid var(--accent); margin-left: -2px; }
.msg-pin { position: absolute; left: -7px; top: 5px; width: 14px; height: 14px; }
.msg-pin svg { width: 12px; height: 12px; color: var(--accent); }
.msg-conv-body { flex: 1; min-width: 0; overflow: hidden; text-align: left; }
.msg-conv-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-bottom: 2px; }
.msg-conv-name { flex: 1 1 auto; display: block; min-width: 0; max-width: 100%; font-size: var(--text-md); font-weight: var(--weight-semibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-conv-time { font-size: var(--text-xs); color: var(--fg-tertiary); flex-shrink: 0; }
.msg-conv-last { display: block; min-width: 0; max-width: 100%; font-size: var(--text-sm); color: var(--fg-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-tag { margin-right: 4px; }
.msg-mention { color: var(--accent); font-weight: var(--weight-semibold); }
.msg-badge { flex: 0 0 auto; padding: 1px 6px; background: var(--danger); color: white; font-size: 10px; font-weight: var(--weight-semibold); border-radius: var(--r-full); }
.msg-badge-dot { flex: 0 0 auto; width: 8px; height: 8px; background: var(--danger); border-radius: 50%; }
.msg-group-avatars { position: relative; width: 36px; height: 36px; flex-shrink: 0; }
.msg-group-avatars .avatar { position: absolute; border: 2px solid var(--bg-elevated); }
.msg-group-avatars .avatar:first-child { top: 0; left: 0; }
.msg-group-avatars .avatar:last-child { bottom: 0; right: 0; }

.new-chat-modal { max-width: 520px; }
.new-chat-people { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.new-chat-person {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--bg-elevated); text-align: left;
  transition: all var(--t-fast) var(--ease-out);
}
.new-chat-person:hover { border-color: var(--border-strong); background: var(--bg-subtle); }
.new-chat-person.selected { border-color: var(--accent); background: var(--accent-soft); }
.new-chat-person > span { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.new-chat-person strong { font-size: var(--text-md); font-weight: var(--weight-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.new-chat-person em { font-size: var(--text-xs); color: var(--fg-tertiary); font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.new-chat-person i { font-size: var(--text-xs); color: var(--fg-secondary); font-style: normal; font-weight: var(--weight-semibold); }
.new-chat-person.selected i { color: var(--accent); }

.message-call-banner {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 48px;
  padding: var(--s-2) var(--s-4);
  border-bottom: 1px solid var(--border-subtle);
  background: linear-gradient(90deg, var(--accent-soft), var(--bg-elevated));
}
.message-call-pulse {
  position: relative;
  width: 10px;
  height: 10px;
  border-radius: var(--r-full);
  background: var(--success);
  box-shadow: 0 0 0 4px oklch(0.72 0.14 150 / 0.16);
  flex-shrink: 0;
}
.message-call-pulse::after {
  content: "";
  position: absolute;
  inset: -5px;
  border: 1px solid oklch(0.72 0.14 150 / 0.38);
  border-radius: inherit;
  animation: callPulse 1.4s var(--ease-out) infinite;
}
.message-call-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}
.message-call-main strong {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--fg);
}
.message-call-main em {
  font-style: normal;
  font-size: var(--text-xs);
  color: var(--fg-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@keyframes callPulse {
  from { transform: scale(0.75); opacity: 0.8; }
  to { transform: scale(1.55); opacity: 0; }
}

.quick-create-popover {
  position: fixed;
  z-index: 1600;
  display: none;
  max-height: calc(100vh - 96px);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-5);
  overflow: hidden;
}
.quick-create-popover.open {
  display: block;
  animation: slideDown 180ms var(--ease-out);
}
.quick-create-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border-subtle);
}
.quick-create-head strong {
  display: block;
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}
.quick-create-head span {
  color: var(--fg-secondary);
  font-size: var(--text-sm);
}
.quick-create-body {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  min-height: 360px;
}
.quick-create-types {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--s-3);
  border-right: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
}
.quick-type {
  display: grid;
  grid-template-columns: 28px 1fr;
  column-gap: 10px;
  row-gap: 2px;
  align-items: center;
  width: 100%;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: var(--fg-secondary);
  text-align: left;
  transition: all var(--t-fast) var(--ease-out);
}
.quick-type:hover {
  background: var(--bg-elevated);
  border-color: var(--border);
}
.quick-type.active {
  background: var(--bg-elevated);
  border-color: var(--accent);
  color: var(--fg-primary);
  box-shadow: var(--shadow-1);
}
.quick-type span {
  grid-row: 1 / span 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent);
}
.quick-type b {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.quick-type em {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-style: normal;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quick-create-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
  align-content: start;
  padding: var(--s-5);
}
.quick-context {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
}
.quick-context span {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}
.quick-context strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.quick-conflict {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid color-mix(in oklab, var(--warning) 34%, var(--border));
  border-radius: var(--r-sm);
  background: color-mix(in oklab, var(--warning) 9%, var(--bg-elevated));
}
.quick-conflict.confirmed {
  border-color: color-mix(in oklab, var(--accent) 38%, var(--border));
  background: color-mix(in oklab, var(--accent) 8%, var(--bg-elevated));
}
.quick-conflict[hidden] { display: none; }
.quick-conflict strong {
  color: var(--warning);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.quick-conflict.confirmed strong { color: var(--accent); }
.quick-conflict span {
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
}
.quick-create-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.quick-create-form .wide,
.quick-create-form button[type="submit"] {
  grid-column: 1 / -1;
}
.quick-create-form textarea.input-wrap {
  width: 100%;
  min-height: 82px;
  resize: vertical;
  border: 1px solid var(--border);
}
.quick-create-form select[multiple] {
  min-height: 136px;
}
.quick-create-form button[type="submit"] {
  justify-self: end;
}

.contact-directory {
  flex-shrink: 0;
  padding: var(--s-3);
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-elevated), var(--bg-raised));
}
.contact-dir-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-2); font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.contact-dir-actions { display: inline-flex; align-items: center; gap: 6px; }
.contact-dir-actions .btn { gap: 4px; padding-inline: 8px; }
.contact-dir-actions .lucide,
.contact-empty .lucide { width: 13px; height: 13px; }
.contact-filter-row { display: flex; gap: 4px; margin-bottom: var(--s-2); overflow: hidden; }
.contact-filter { padding: 3px 8px; border-radius: var(--r-full); font-size: var(--text-xs); color: var(--fg-secondary); background: var(--bg-subtle); transition: all var(--t-fast) var(--ease-out); }
.contact-filter.active,
.contact-filter:hover { color: var(--accent); background: var(--accent-soft); }
.contact-list { display: flex; flex-direction: column; gap: 4px; }
.contact-card {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 7px;
  border-radius: var(--r-md);
  text-align: left;
  transition: background var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
.contact-card:hover,
.contact-card:focus-visible { background: var(--bg-subtle); outline: none; }
.contact-card:active { transform: scale(0.995); }
.contact-card.favorite { background: color-mix(in oklab, var(--accent-soft) 62%, var(--bg-elevated)); }
.contact-card.member-suggestion { border-color: color-mix(in oklab, var(--border) 80%, var(--accent)); }
.contact-card.member-suggestion .contact-card-star { display: none; }
.contact-card.selected {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}
.contact-card.is-focused,
.report-card.is-focused,
.template-setting-card.is-focused {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 16%, transparent), var(--shadow-1);
}
.contact-card-body { flex: 1; min-width: 0; }
.contact-card-main { display: flex; align-items: center; gap: 6px; min-width: 0; }
.contact-card-main span { font-size: var(--text-sm); font-weight: var(--weight-semibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-card-main em { font-style: normal; font-size: 10px; color: var(--fg-tertiary); white-space: nowrap; }
.contact-card-sub { font-size: var(--text-xs); color: var(--fg-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-tags {
  display: flex;
  gap: 4px;
  min-width: 0;
  margin-top: 3px;
  overflow: hidden;
}
.contact-tag {
  flex-shrink: 0;
  padding: 1px 5px;
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  color: var(--fg-tertiary);
  font-size: 10px;
  line-height: 1.4;
}
.contact-request-meta {
  margin-top: 3px;
  overflow: hidden;
  color: var(--fg-tertiary);
  font-size: 10px;
  font-weight: var(--weight-medium);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact-card-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex-shrink: 0;
  max-width: 92px;
}
.contact-card-star {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--fg-tertiary);
  transition: all var(--t-fast) var(--ease-out);
}
.contact-card-star:hover,
.contact-card-star.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.contact-card-star .lucide { width: 13px; height: 13px; }
.contact-template-pill {
  flex-shrink: 0;
  max-width: 92px;
  padding: 2px 6px;
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  font-size: 10px;
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-source-pill {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  color: var(--fg-tertiary);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

.msg-mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--border-subtle);
}
.msg-mode-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  padding: 7px 10px;
  border-radius: var(--r-md);
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  transition: all var(--t-fast) var(--ease-out);
}
.msg-mode-btn .lucide { width: 14px; height: 14px; }
.msg-mode-btn:hover { background: var(--bg-subtle); color: var(--fg); }
.msg-mode-btn.active { background: var(--accent-soft); color: var(--accent); }
.msg-sidebar:not(.contacts-mode) .contact-directory { display: none; }
.msg-sidebar.contacts-mode .msg-side-tabs,
.msg-sidebar.contacts-mode .msg-list { display: none; }
.msg-sidebar.contacts-mode .contact-directory {
  display: flex;
  flex: 1;
  min-height: 0;
}
.contact-directory {
  flex-direction: column;
  overflow: hidden;
  padding: var(--s-3);
}
.contact-shortcuts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: var(--s-3);
}
.contact-shortcut {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 8px;
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  text-align: left;
  transition: all var(--t-fast) var(--ease-out);
}
.contact-shortcut:hover,
.contact-shortcut.active { background: var(--accent-soft); color: var(--accent); }
.contact-shortcut span {
  width: 24px;
  height: 24px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
}
.contact-shortcut .lucide { width: 13px; height: 13px; }
.contact-shortcut strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.contact-shortcut em {
  font-style: normal;
  font-size: 10px;
  color: var(--fg-tertiary);
}
.contact-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}
.contact-section { margin-bottom: var(--s-2); }
.contact-section[hidden],
.contact-card[hidden] { display: none; }
.contact-section-title {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 7px 4px 5px;
  background: linear-gradient(180deg, var(--bg-raised), color-mix(in oklab, var(--bg-raised) 88%, transparent));
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.contact-empty {
  padding: var(--s-5) var(--s-3);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  color: var(--fg-tertiary);
  text-align: center;
}
.contact-empty strong {
  display: block;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  margin-bottom: 4px;
}
.contact-empty span { font-size: var(--text-xs); }
.contact-empty .btn { margin-top: var(--s-3); }
.modal.contact-add-modal {
  width: min(720px, calc(100vw - 48px));
  max-width: min(720px, calc(100vw - 48px));
}
.contact-add-modal form { margin: 0; }
.contact-add-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--s-2);
  align-items: center;
}
.contact-add-search .input-wrap { min-height: 38px; }
.contact-add-search input {
  width: 100%;
  color: var(--fg);
}
.contact-add-note {
  margin-top: var(--s-3);
  padding: 9px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
}
.contact-add-results,
.contact-friend-request-list {
  display: grid;
  gap: 8px;
}
.contact-add-results { margin-top: var(--s-3); }
.contact-add-empty {
  padding: var(--s-4);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  color: var(--fg-tertiary);
  font-size: var(--text-sm);
  text-align: center;
}
.contact-add-result,
.contact-friend-request-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
}
.contact-add-result-main,
.contact-friend-request-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.contact-add-result-main strong,
.contact-friend-request-main strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg);
  font-size: var(--text-sm);
}
.contact-add-result-main span,
.contact-friend-request-main span,
.contact-friend-request-main p {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
}
.contact-friend-request-main p {
  margin: 2px 0 0;
  color: var(--fg-secondary);
}
.contact-add-state {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-style: normal;
  white-space: nowrap;
}
.contact-friend-request-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-4);
  margin-top: var(--s-4);
}
.contact-friend-request-panels section {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: var(--s-2);
}
.contact-friend-request-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  position: relative;
}
.contact-friend-request-row .contact-request-state {
  justify-self: start;
}
.contact-friend-request-actions {
  grid-column: 2 / 4;
  display: flex;
  gap: 6px;
}
.contact-add-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
}
.contact-add-modal textarea {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  color: var(--fg);
}
.contact-note-modal { width: min(440px, calc(100vw - 40px)); }
.contact-note-modal textarea {
  width: 100%;
  resize: vertical;
  min-height: 96px;
  color: var(--fg);
}
.contact-note-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}
.contact-note-summary strong {
  display: block;
  font-size: var(--text-sm);
}
.contact-note-summary span {
  display: block;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
}

.msg-main.contact-profile-mode .msg-stream,
.msg-main.contact-profile-mode .msg-composer,
.msg-main.contact-profile-mode [data-message-call-banner] {
  display: none;
}
.contact-profile-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--s-6);
  background: var(--bg);
}
.contact-profile-panel[hidden] { display: none; }
.contact-profile-card {
  width: min(720px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.contact-profile-hero {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-5);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-1);
}
.contact-profile-hero .avatar {
  width: 58px;
  height: 58px;
  font-size: var(--text-lg);
}
.contact-profile-main {
  flex: 1;
  min-width: 0;
}
.contact-profile-kicker {
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.contact-profile-main h2 {
  margin-top: 2px;
  color: var(--fg);
  font-size: 26px;
  line-height: var(--leading-tight);
}
.contact-profile-main p {
  margin-top: 4px;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
}
.contact-profile-star {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  color: var(--fg-tertiary);
  background: var(--bg-subtle);
}
.contact-profile-star.active,
.contact-profile-star:hover {
  color: var(--accent);
  background: var(--accent-soft);
}
.contact-profile-star .lucide { width: 16px; height: 16px; }
.contact-profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}
.contact-profile-actions .btn {
  gap: 7px;
}
.contact-profile-actions .lucide {
  width: 15px;
  height: 15px;
}
.contact-profile-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-3);
}
.contact-profile-metric {
  min-width: 0;
  padding: var(--s-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
}
.contact-profile-metric strong,
.contact-profile-metric span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact-profile-metric strong {
  color: var(--fg);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}
.contact-profile-metric span {
  margin-top: 4px;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
}
.contact-profile-section {
  padding: var(--s-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
}
.contact-profile-label {
  margin-bottom: var(--s-2);
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.contact-profile-section p {
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}
.contact-profile-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.contact-profile-tags span,
.contact-profile-tags em {
  padding: 4px 8px;
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-style: normal;
}
.contact-profile-template-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-2);
}
.contact-profile-template {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
  padding: var(--s-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg);
  text-align: left;
}
.contact-profile-template:hover,
.contact-profile-template.recommended {
  border-color: color-mix(in oklab, var(--accent) 32%, var(--border));
  background: var(--accent-soft);
}
.contact-profile-template span {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
  color: var(--accent);
}
.contact-profile-template .lucide {
  width: 15px;
  height: 15px;
}
.contact-profile-template strong {
  min-width: 0;
  overflow: hidden;
  color: var(--fg);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact-profile-template em {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-style: normal;
  white-space: nowrap;
}
.contact-request-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.contact-request-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-3);
  min-width: 0;
  padding: var(--s-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg);
}
.contact-request-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 5px 7px;
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}
.contact-request-state.progress,
.contact-request-state.review {
  background: rgba(59, 130, 246, .10);
  color: #2563eb;
}
.contact-request-state.done {
  background: rgba(16, 185, 129, .12);
  color: #059669;
}
.contact-request-state.blocked {
  background: rgba(239, 68, 68, .10);
  color: #dc2626;
}
.contact-request-main {
  min-width: 0;
}
.contact-request-main strong,
.contact-request-main em,
.contact-request-main p {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact-request-main strong {
  color: var(--fg);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.contact-request-main em {
  margin-top: 2px;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-style: normal;
}
.contact-request-main p {
  margin-top: 4px;
  color: var(--fg-secondary);
  font-size: var(--text-xs);
}
.contact-request-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.contact-request-actions .btn {
  min-height: 28px;
  padding-inline: 10px;
}
.contact-profile-empty {
  padding: var(--s-3);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  color: var(--fg-tertiary);
  font-size: var(--text-sm);
  text-align: center;
}

.msg-main { display: flex; flex-direction: column; background: var(--bg); min-width: 0; min-height: 0; }
.msg-main-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-3) var(--s-5);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.msg-main-title { display: flex; align-items: center; gap: 10px; }
.msg-title-name { font-size: var(--text-md); font-weight: var(--weight-semibold); }
.msg-title-meta { font-size: var(--text-xs); color: var(--fg-secondary); }
.msg-main-actions { display: flex; gap: 2px; }
/* P1-12: 删除 online-dots 死代码（CSS gap 不支持负值，且无 HTML 对应） */

.msg-stream { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: var(--s-5) var(--s-6); display: flex; flex-direction: column; gap: var(--s-4); }
.msg-stream > * { flex-shrink: 0; }
.msg-day-divider { display: flex; align-items: center; align-self: center; width: 100%; max-width: 960px; gap: var(--s-3); color: var(--fg-tertiary); font-size: var(--text-xs); font-weight: var(--weight-medium); }
.msg-day-divider::before, .msg-day-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.msg-day-divider span { padding: 2px 10px; background: var(--bg); border-radius: var(--r-full); }

.msg-row { display: flex; align-self: flex-start; gap: 10px; width: fit-content; max-width: min(720px, 74%); }
.msg-row.mine { align-self: flex-end; margin-left: 0; flex-direction: row-reverse; }
.msg-row-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; max-width: 100%; flex: 0 1 auto; }
.msg-row.mine .msg-row-body { align-items: flex-end; }
.msg-row-head { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); }
.msg-author { font-weight: var(--weight-semibold); }
.msg-time { color: var(--fg-tertiary); }
.msg-mini-action {
  min-height: 22px;
  padding: 0 7px;
  color: var(--fg-tertiary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  opacity: .46;
  transition: opacity var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
}
.msg-row:hover .msg-mini-action,
.msg-row:focus-within .msg-mini-action,
.msg-mini-action.done { opacity: 1; background: var(--bg-subtle); }
.msg-mini-action:hover,
.msg-mini-action.done {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
  background: var(--accent-soft);
}
.msg-bubble {
  padding: 9px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  border-top-left-radius: var(--r-xs);
  font-size: var(--text-md);
  line-height: var(--leading-snug);
  box-shadow: var(--shadow-1);
  width: fit-content;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.msg-row.is-focused .msg-bubble {
  border-color: color-mix(in oklab, var(--accent) 48%, var(--border));
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-2);
}
.bubble-mine { background: var(--accent); color: var(--fg-on-accent); border-color: var(--accent); border-top-left-radius: var(--r-lg); border-top-right-radius: var(--r-xs); }
.bubble-mine b { font-weight: var(--weight-semibold); }
.msg-attachment {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-top: 4px;
  width: min(360px, 100%);
  max-width: 100%;
}
.attach-icon { width: 36px; height: 36px; background: var(--c, var(--accent)); color: white; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; font-size: 16px; }
.attach-body { flex: 1; min-width: 0; }
.attach-name { font-size: var(--text-md); font-weight: var(--weight-medium); }
.attach-meta { font-size: var(--text-xs); color: var(--fg-tertiary); }
.msg-attachment .attach-name,
.composer-attachment-chip .attach-name,
.attachment-picker-item .attach-name,
.msg-attachment .attach-meta,
.composer-attachment-chip .attach-meta,
.attachment-picker-item .attach-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-task-draft,
.message-schedule-draft,
.message-report-draft {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(460px, 100%);
  margin-top: 4px;
  padding: 10px;
  background: color-mix(in srgb, var(--accent-soft) 34%, var(--bg-elevated));
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}
.message-schedule-draft {
  background: color-mix(in srgb, var(--success-soft) 28%, var(--bg-elevated));
  border-color: color-mix(in srgb, var(--success) 20%, var(--border));
}
.message-report-draft {
  background: color-mix(in srgb, var(--warning-soft) 26%, var(--bg-elevated));
  border-color: color-mix(in srgb, var(--warning) 22%, var(--border));
}
.message-task-draft.is-sending,
.message-schedule-draft.is-sending,
.message-report-draft.is-sending {
  opacity: .84;
}
.message-task-draft-head,
.message-task-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.message-task-draft-head strong {
  font-size: var(--text-sm);
}
.message-task-draft-head .icon-btn {
  width: 26px;
  height: 26px;
}
.message-task-title,
.message-task-grid select,
.message-task-grid input {
  width: 100%;
  min-width: 0;
  color: var(--fg);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: var(--text-sm);
}
.message-task-title {
  height: 34px;
  padding: 0 9px;
  font-weight: var(--weight-medium);
}
.message-task-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.message-task-grid .span-2 {
  grid-column: 1 / -1;
}
.message-task-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.message-task-grid span,
.message-task-foot span {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
}
.message-task-grid select,
.message-task-grid input {
  height: 32px;
  padding: 0 7px;
}
.message-task-foot span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-task-foot .btn {
  flex-shrink: 0;
}
.message-report-preview {
  padding: 8px 9px;
  color: var(--fg-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.msg-agent-card {
  align-self: flex-start;
  width: min(720px, 100%);
  max-width: min(720px, 100%);
  background: linear-gradient(135deg, var(--accent-soft) 0%, var(--bg-elevated) 50%, var(--bg-elevated) 100%);
  border: 1px solid var(--accent);
  border-radius: var(--r-lg);
  overflow: hidden;
  position: relative;
}
.msg-agent-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--primary-500), var(--accent-purple), var(--accent-pink));
  background-size: 200% 100%;
  animation: agentShine 3s var(--ease-in-out) infinite;
}
@keyframes agentShine { to { background-position: -200% 0; } }
.agent-card-head { display: flex; align-items: center; gap: 10px; padding: var(--s-3) var(--s-4); background: var(--bg-elevated); border-bottom: 1px solid var(--border); }
.agent-card-head > div:last-child { min-width: 0; }
.agent-avatar { width: 32px; height: 32px; background: linear-gradient(135deg, var(--primary-500), var(--accent-purple)); border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; font-size: 14px; color: white; }
.agent-name { font-size: var(--text-md); font-weight: var(--weight-semibold); }
.agent-status { font-size: var(--text-xs); color: var(--fg-secondary); display: flex; align-items: center; gap: 4px; }
.agent-card-body { padding: var(--s-4); }
.agent-section { margin-bottom: var(--s-3); }
.agent-section-title { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--fg); margin-bottom: 6px; }
.agent-list { font-size: var(--text-sm); color: var(--fg); line-height: var(--leading-relaxed); }
.agent-list li { padding-left: 14px; position: relative; margin-bottom: 4px; }
.agent-list li::before { content: '•'; position: absolute; left: 0; color: var(--accent); }
.agent-list .check { margin-right: 6px; vertical-align: middle; width: 14px; height: 14px; }
.agent-list .check-box { border-radius: 3px; }
.agent-list .check input:checked + .check-box::after { font-size: 9px; }
.agent-card-foot { display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--border); }

.msg-composer { flex-shrink: 0; background: var(--bg-elevated); border-top: 1px solid var(--border); padding: var(--s-3) var(--s-5) var(--s-4); }
.template-draft {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: var(--s-3);
  padding: 10px;
  border: 1px solid var(--accent-soft-strong);
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--accent-soft), var(--bg-elevated));
}
.template-draft.is-hidden { display: none; }
.template-draft-icon { width: 32px; height: 32px; border-radius: var(--r-md); background: var(--accent); color: var(--fg-on-accent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.template-draft-body { flex: 1; min-width: 0; }
.template-draft-title { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.template-draft-desc { font-size: var(--text-xs); color: var(--fg-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-toolbar { display: flex; align-items: center; gap: 2px; margin-bottom: 8px; }
.composer-toolbar-right { margin-left: auto; }
.composer-attachment-tray {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.composer-attachment-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(420px, 100%);
  padding: 8px;
  margin-bottom: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.composer-attachment-chip .icon-btn {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.attachment-picker {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 45;
  width: min(440px, calc(100vw - 96px));
  padding: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-5);
}
.template-picker {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 45;
  width: min(420px, calc(100vw - 96px));
  padding: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-5);
}
.attachment-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.attachment-picker-head strong { font-size: var(--text-sm); }
.template-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.template-picker-head strong { font-size: var(--text-sm); }
.attachment-picker-search { margin-bottom: 8px; }
.attachment-picker-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 292px;
  overflow-y: auto;
}
.template-picker-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
}
.attachment-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  color: var(--fg);
  text-align: left;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
}
.attachment-picker-item:hover {
  background: var(--bg-subtle);
  border-color: var(--border-subtle);
}
.template-picker-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 2px 10px;
  width: 100%;
  padding: 9px 10px;
  color: var(--fg);
  text-align: left;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
}
.template-picker-item:hover,
.template-picker-item:focus-visible {
  outline: none;
  background: var(--bg-subtle);
  border-color: var(--border-subtle);
}
.template-picker-item span {
  grid-row: span 2;
  align-self: start;
  width: max-content;
  max-width: 56px;
  padding: 2px 7px;
  overflow: hidden;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.template-picker-item strong {
  min-width: 0;
  overflow: hidden;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.template-picker-item em {
  min-width: 0;
  overflow: hidden;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-picker-item .attach-icon {
  width: 34px;
  height: 34px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.attachment-picker-empty {
  padding: 14px;
  color: var(--fg-tertiary);
  background: var(--bg-subtle);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
}
.attachment-picker-empty strong {
  display: block;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  margin-bottom: 4px;
}
.attachment-picker-empty span { font-size: var(--text-xs); }
.template-picker-empty {
  padding: 14px;
  color: var(--fg-tertiary);
  background: var(--bg-subtle);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
}
.template-picker-empty strong {
  display: block;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  margin-bottom: 4px;
}
.template-picker-empty span { font-size: var(--text-xs); }
/* R11: 让 send-btn 独占紫色，ai-trigger 用中性色 */
.ai-trigger { background: var(--bg-subtle); color: var(--fg); border: 1px solid transparent; font-size: var(--text-sm); padding: 4px 10px; }
.ai-trigger:hover { background: var(--bg-muted); }
.msg-composer textarea { width: 100%; padding: 10px 0; font-size: var(--text-md); line-height: 1.55; resize: none; min-height: 52px; max-height: 184px; overflow-y: hidden; color: var(--fg); }
.msg-composer.is-sending { opacity: .86; }
.msg-composer.is-sending textarea,
.msg-composer.is-sending .send-btn { cursor: wait; }
.template-draft.is-sending { opacity: .86; }
.template-draft.is-sending button { cursor: wait; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.composer-hint { display: flex; gap: 12px; font-size: var(--text-xs); color: var(--fg-tertiary); }
.composer-hint kbd { padding: 1px 4px; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--r-xs); font-size: 10px; font-family: var(--font-mono); }
.composer-hint [data-message-draft-hint] { color: var(--accent); font-weight: var(--weight-semibold); }
.msg-composer[data-has-draft="true"] textarea::placeholder { color: var(--fg-tertiary); }
.send-btn { background: var(--accent); color: var(--fg-on-accent); padding: 6px 14px; }
.send-btn:hover { background: var(--accent-hover); }
.ai-tag { display: inline-flex; align-items: center; gap: 2px; padding: 1px 6px; background: var(--accent-soft); color: var(--accent-purple); border-radius: var(--r-sm); font-size: var(--text-sm); font-weight: var(--weight-medium); }

.msg-detail {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  width: 320px;
  max-width: min(320px, calc(100vw - var(--side-w) - 32px));
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-5);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  transition:
    transform var(--t-mid) var(--ease-emph),
    opacity var(--t-fast) var(--ease-out),
    visibility var(--t-fast) var(--ease-out);
}
.msg-detail.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(calc(100% + 16px));
}
.msg-detail-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-4); border-bottom: 1px solid var(--border-subtle); }
.msg-detail-head h3 { font-size: var(--text-md); font-weight: var(--weight-semibold); }
.msg-detail-body { padding: var(--s-2); }
.detail-section { padding: var(--s-3); border-bottom: 1px solid var(--border-subtle); }
.detail-section:last-child { border-bottom: none; }
.detail-section-title { font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--fg-tertiary); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: var(--s-2); display: flex; align-items: center; }
.detail-section-title span { color: var(--fg-tertiary); margin-left: 4px; font-weight: var(--weight-normal); text-transform: none; letter-spacing: 0; }
.detail-section-content { font-size: var(--text-sm); color: var(--fg); line-height: var(--leading-relaxed); }
.message-topic-card {
  display: grid;
  gap: var(--s-2);
}
.message-topic-card .detail-section-content {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}
.message-topic-card .btn {
  justify-self: start;
}
.message-topic-editor {
  display: grid;
  gap: var(--s-2);
}
.message-topic-editor textarea {
  width: 100%;
  min-height: 78px;
  resize: vertical;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  color: var(--fg);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}
.message-topic-editor textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.message-topic-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
}
.message-channel-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-2);
}
.message-channel-actions .btn {
  justify-content: center;
  min-width: 0;
}
.message-channel-actions .btn.active {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
  background: var(--accent-soft);
}
.message-channel-state {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--s-2);
}
.message-channel-state span {
  min-width: 0;
  padding: 2px 7px;
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}
.member-list { display: flex; flex-direction: column; gap: 2px; }
.member-item { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: var(--r-sm); transition: all var(--t-fast) var(--ease-out); cursor: pointer; }
.member-item:hover { background: var(--bg-subtle); }
.member-item .avatar { width: 24px; height: 24px; font-size: 10px; }
.member-name { font-size: var(--text-sm); flex: 1; }
.role-tag { font-size: 10px; padding: 1px 5px; border-radius: var(--r-sm); font-weight: var(--weight-semibold); }
.role-tag.owner { background: var(--accent-soft); color: var(--accent); }
.role-tag.bot { background: oklch(0.95 0.04 305); color: var(--accent-purple); }
.resource-list { display: flex; flex-direction: column; gap: 2px; }
.resource-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 6px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: inherit;
  text-align: left;
  transition: all var(--t-fast) var(--ease-out);
  cursor: pointer;
}
.resource-item:hover { background: var(--bg-subtle); }
.resource-item:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.resource-icon { width: 28px; height: 28px; background: var(--c, var(--accent)); color: white; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; font-size: 12px; }
.resource-body { flex: 1; min-width: 0; }
.resource-name { font-size: var(--text-sm); font-weight: var(--weight-medium); }
.resource-meta { font-size: var(--text-xs); color: var(--fg-tertiary); }

.contact-context-menu {
  position: fixed;
  z-index: 1400;
  width: 260px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-5);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(4px) scale(0.98);
  transition: opacity var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out), visibility var(--t-fast) var(--ease-out);
}
.contact-context-menu.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.context-menu-head { padding: 8px 8px 6px; }
.context-menu-title { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.context-menu-sub { font-size: var(--text-xs); color: var(--fg-tertiary); }
.context-menu-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  color: var(--fg);
  text-align: left;
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.context-menu-item:hover { background: var(--bg-subtle); color: var(--accent); }
.context-menu-item.recommended {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 58%, var(--bg-elevated));
}
.context-menu-icon { width: 18px; height: 18px; color: var(--fg-tertiary); display: flex; align-items: center; justify-content: center; }
.context-menu-item.recommended .context-menu-icon { color: var(--accent); }
.context-menu-icon svg { width: 15px; height: 15px; }
.context-menu-item:hover .context-menu-icon { color: var(--accent); }
.context-menu-item em { margin-left: auto; font-style: normal; font-size: 10px; color: var(--fg-tertiary); }
.context-menu-sep { height: 1px; background: var(--border-subtle); margin: 4px 2px; }

/* ============================================================
   Projects (Kanban)
   ============================================================ */
.proj-tabs { display: flex; align-items: center; gap: 2px; padding: 3px; background: var(--bg-subtle); border-radius: var(--r-md); margin-bottom: var(--s-4); width: fit-content; border: 1px solid var(--border); }
.proj-tab { display: flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--fg-secondary); border-radius: var(--r-sm); transition: all var(--t-fast) var(--ease-out); }
.proj-tab.active { background: var(--bg-elevated); color: var(--fg); box-shadow: var(--shadow-1); }
.proj-tab-count { font-size: 10px; padding: 0 5px; background: var(--bg-elevated); color: var(--fg-secondary); border-radius: var(--r-full); font-weight: var(--weight-semibold); }
.proj-tab.active .proj-tab-count { background: var(--accent-soft); color: var(--accent); }
.proj-tab.add { padding: 6px 8px; }
.head-actions { position: relative; }
.project-lifecycle-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 34px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}
.project-lifecycle-actions[hidden] { display: none; }
.project-lifecycle-status {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}
.project-lifecycle-actions .btn {
  height: 26px;
  min-height: 26px;
  padding: 0 8px;
  white-space: nowrap;
}
.head-actions .btn[data-project-filter-toggle].active {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--border));
  background: var(--accent-soft);
}
.project-filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-full);
  background: var(--accent);
  color: var(--fg-on-accent);
  font-size: 10px;
  font-weight: var(--weight-bold);
}
.project-filter-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 76px;
  z-index: 50;
  width: 280px;
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-5);
}
.project-filter-panel[hidden] { display: none; }
.project-filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin-bottom: var(--s-2);
}
.project-filter-head strong { font-size: var(--text-sm); }
.project-filter-field {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: var(--s-2);
  padding: 7px 0;
  border-top: 1px solid var(--border-subtle);
}
.project-filter-field span {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.project-filter-field select {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--fg);
  font: inherit;
  font-size: var(--text-sm);
}
.project-filter-field-wide {
  grid-template-columns: 64px minmax(0, 1fr);
}
.project-filter-search {
  min-width: 0;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
}
.project-filter-search svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.project-filter-search input {
  min-width: 0;
  width: 100%;
  color: var(--fg);
  font-size: var(--text-sm);
}
.project-filter-search input::placeholder { color: var(--fg-muted); }
.project-filter-field select:focus-visible,
.project-filter-search:focus-within {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

.kanban { display: flex; gap: var(--s-3); overflow-x: auto; padding-bottom: var(--s-4); }
.kanban-col { flex: 0 0 280px; background: var(--bg-subtle); border-radius: var(--r-lg); padding: var(--s-3); display: flex; flex-direction: column; gap: var(--s-2); min-height: 400px; border: 1px solid transparent; transition: border-color var(--t-fast); }
.kanban-col.drag-over { border-color: var(--accent); background: var(--accent-soft); }
.kanban-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px; }
.kanban-head-left { display: flex; align-items: center; gap: 6px; font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.kanban-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.kanban-count { font-size: var(--text-xs); padding: 0 6px; background: var(--bg-elevated); color: var(--fg-secondary); border-radius: var(--r-full); font-weight: var(--weight-semibold); }

.task-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid transparent; /* P1-15: 默认留出位置给 priority 高亮 */
  border-radius: var(--r-md);
  padding: var(--s-3);
  cursor: grab;
  transition: border-color var(--t-fast) var(--ease-out), border-top-color var(--t-fast) var(--ease-out), border-right-color var(--t-fast) var(--ease-out), border-bottom-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
  position: relative;
}
.task-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-3); border-top-color: var(--border-strong); border-right-color: var(--border-strong); border-bottom-color: var(--border-strong); /* R10: 不改 border-left，避免优先级条闪烁 */ }
.task-card.dragging { opacity: 0.4; cursor: grabbing; }
.task-card.done { opacity: 0.6; }
.task-card.done .task-title { text-decoration: line-through; color: var(--fg-tertiary); }
.task-card.review { border-left: 3px solid var(--warning); }
.task-card.priority { border-left: 3px solid var(--danger); }
.task-tags { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.task-title { font-size: var(--text-md); font-weight: var(--weight-medium); line-height: var(--leading-snug); margin-bottom: 6px; }
.task-desc { font-size: var(--text-sm); color: var(--fg-secondary); line-height: var(--leading-snug); margin-bottom: 10px; }
.task-progress { height: 3px; background: var(--bg-subtle); border-radius: var(--r-full); margin-bottom: 10px; overflow: hidden; }
.task-progress > div { height: 100%; background: var(--accent); border-radius: var(--r-full); }
.task-foot { display: flex; align-items: center; justify-content: space-between; }
.task-meta { display: flex; align-items: center; gap: 8px; font-size: var(--text-xs); color: var(--fg-tertiary); }
.task-meta-item { display: flex; align-items: center; gap: 3px; }
.task-due.overdue { color: var(--danger); font-weight: var(--weight-semibold); }
.task-due.due-soon { color: var(--warning); font-weight: var(--weight-semibold); }
.kanban-add-col { display: flex; align-items: center; justify-content: center; background: transparent; border: 2px dashed var(--border); min-height: 200px; transition: all var(--t-fast); }
.kanban-add-col:hover { border-color: var(--accent); background: var(--accent-soft); }
.kanban-add-btn { display: flex; align-items: center; gap: 6px; padding: 8px 12px; font-size: var(--text-sm); color: var(--fg-tertiary); border-radius: var(--r-md); transition: all var(--t-fast) var(--ease-out); font-weight: var(--weight-medium); }
.kanban-add-btn:hover { color: var(--accent); }

.kanban[hidden],
.project-alt-view[hidden] { display: none !important; }
.project-alt-view { min-height: 360px; }
.project-table, .project-gantt, .project-timeline { display: flex; flex-direction: column; gap: var(--s-2); }
.project-table { border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--bg-elevated); }
.project-table-row {
  display: grid; grid-template-columns: minmax(260px, 1.6fr) 120px 92px 140px 150px;
  align-items: center; gap: var(--s-3); width: 100%;
  padding: 12px 14px; text-align: left; font-size: var(--text-sm);
  border-bottom: 1px solid var(--border-subtle);
}
.project-table-row:not(.head):hover { background: var(--bg-subtle); }
.project-table-row:last-child { border-bottom: 0; }
.project-table-row.head { background: var(--bg-subtle); color: var(--fg-secondary); font-weight: var(--weight-semibold); cursor: default; }
.project-table-title, .project-gantt-meta, .project-timeline-body { display: flex; flex-direction: column; min-width: 0; }
.project-table-title strong, .project-gantt-meta strong, .project-timeline-body strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: var(--weight-semibold); }
.project-table-title em, .project-gantt-meta em, .project-timeline-body em { color: var(--fg-tertiary); font-size: var(--text-xs); font-style: normal; }
.project-table-row > span { min-width: 0; display: flex; align-items: center; gap: 6px; }
.project-status-dot { width: 8px; height: 8px; border-radius: var(--r-full); background: var(--c); flex: 0 0 auto; }
.project-gantt-row {
  display: grid; grid-template-columns: 260px minmax(0, 1fr);
  align-items: center; gap: var(--s-4); padding: 14px;
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--bg-elevated); text-align: left;
}
.project-gantt-row:hover, .project-timeline-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.project-gantt-meta { gap: 4px; }
.project-gantt-meta strong { display: flex; align-items: center; gap: 8px; }
.project-gantt-track { height: 28px; border-radius: var(--r-md); background: var(--bg-subtle); overflow: hidden; position: relative; }
.project-gantt-bar {
  min-width: 42px; height: 100%; display: flex; align-items: center; justify-content: flex-end;
  padding-right: 10px; border-radius: inherit; background: color-mix(in oklab, var(--c), white 16%);
  color: white; font-size: var(--text-xs); font-weight: var(--weight-semibold);
}
.project-timeline { position: relative; padding-left: 6px; }
.project-timeline-item {
  display: grid; grid-template-columns: 116px 14px minmax(0, 1fr);
  align-items: stretch; gap: var(--s-3); width: 100%;
  padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--r-lg); background: var(--bg-elevated); text-align: left;
}
.project-timeline-date { color: var(--fg-secondary); font-size: var(--text-xs); font-weight: var(--weight-semibold); }
.project-timeline-line { width: 3px; border-radius: var(--r-full); background: var(--c); }
.project-timeline-body { gap: 4px; }
.project-empty-view {
  padding: 32px; border: 1px dashed var(--border); border-radius: var(--r-lg);
  background: var(--bg-subtle); color: var(--fg-tertiary); text-align: center;
}

/* ============================================================
   Drive
   ============================================================ */
.drive-shell { display: grid; grid-template-columns: 240px minmax(520px, 1fr) 300px; gap: 0; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; min-height: 600px; }
.drive-tree { padding: var(--s-4); border-right: 1px solid var(--border); background: var(--bg-elevated); }
.drive-tree-section { margin-bottom: var(--s-5); }
.drive-tree-title { font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--fg-tertiary); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: var(--s-2); padding: 0 var(--s-2); }
.space-card {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-out);
  margin-bottom: 2px;
}
.space-card:hover { background: var(--bg-subtle); }
.space-card.active { background: var(--accent-soft); }
.space-card.active .space-name { color: var(--accent); }
.space-icon { width: 32px; height: 32px; background: var(--g); border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; font-size: 14px; box-shadow: var(--shadow-1); }
.space-body { flex: 1; min-width: 0; }
.space-name { font-size: var(--text-md); font-weight: var(--weight-semibold); }
.space-meta { font-size: var(--text-xs); color: var(--fg-tertiary); }
.folder-tree { display: flex; flex-direction: column; gap: 1px; }
.folder-item {
  display: flex; align-items: center; gap: 6px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  font-size: var(--text-sm); color: var(--fg);
  text-align: left;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-out);
}
.folder-item:hover { background: var(--bg-subtle); }
.folder-item.active { background: var(--bg-subtle); font-weight: var(--weight-semibold); color: var(--accent); }
.folder-item.sub { padding-left: 28px; color: var(--fg-secondary); font-weight: var(--weight-normal); }
.folder-item.sub.active { color: var(--accent); }
.folder-item.trash { margin-top: var(--s-2); color: var(--fg-secondary); }
.folder-item em {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--fg-tertiary);
  font-size: 11px;
  font-style: normal;
  font-weight: var(--weight-semibold);
}
.folder-item.active em { background: var(--accent-soft); color: var(--accent); }
.folder-dot { width: 4px; height: 4px; background: var(--fg-tertiary); border-radius: 50%; }

.drive-main { display: flex; flex-direction: column; min-width: 0; }
.drive-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
}
.drive-toolbar .breadcrumb { font-size: var(--text-md); min-width: 0; overflow: hidden; white-space: nowrap; }
.drive-toolbar-right { display: flex; gap: var(--s-2); align-items: center; justify-content: flex-end; flex-wrap: wrap; min-width: 0; }
.drive-result-count {
  flex: 0 0 auto;
  font-size: var(--text-xs);
  color: var(--fg-tertiary);
  white-space: nowrap;
}
.drive-search {
  display: flex;
  align-items: center;
  gap: 6px;
  width: min(270px, 30vw);
  min-width: 190px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--fg-tertiary);
}
.drive-search:focus-within {
  border-color: color-mix(in srgb, var(--accent) 46%, var(--border));
  background: var(--bg-elevated);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.drive-search input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--fg);
  font-size: var(--text-sm);
}
.drive-search button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: var(--r-full);
  color: var(--fg-tertiary);
  background: transparent;
}
.drive-search button:hover { background: var(--bg-muted); color: var(--fg); }
.drive-filter-select {
  height: 32px;
  min-width: 92px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  color: var(--fg-secondary);
  font-size: var(--text-sm);
}
.drive-filter-select:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.drive-sort-select { min-width: 112px; }
.drive-scope-control { height: 32px; flex: 0 0 auto; }
.drive-scope-control .seg { min-width: 42px; justify-content: center; padding-inline: 10px; }

.file-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--s-3);
  padding: var(--s-4);
  overflow-y: auto;
  outline: 2px solid transparent;
  outline-offset: -10px;
  transition: background var(--t-fast), outline-color var(--t-fast);
}
.file-grid.is-dragging { background: var(--accent-soft); outline-color: color-mix(in srgb, var(--accent) 34%, transparent); }
.file-card {
  padding: var(--s-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-mid) var(--ease-out);
  position: relative;
  min-width: 0;
}
.file-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-3); border-color: var(--accent); }
.file-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.file-card.folder { background: var(--bg-subtle); }
.file-card.trash { background: color-mix(in srgb, var(--bg-subtle) 72%, var(--bg-elevated)); }
.file-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: flex;
  gap: 4px;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity var(--t-fast), transform var(--t-fast);
}
.file-card:hover .file-actions,
.file-card:focus-within .file-actions { opacity: 1; transform: translateY(0); }
.file-action {
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  box-shadow: var(--shadow-1);
}
.file-action:hover { color: var(--accent); border-color: var(--accent); }
.file-action.active { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 36%, var(--border)); background: var(--accent-soft); }
.file-action.danger:hover { color: var(--danger); border-color: var(--danger); }
.file-icon {
  width: 100%; aspect-ratio: 1;
  background: var(--bg-subtle);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 40px;
  margin-bottom: var(--s-2);
  color: var(--c);
  transition: all var(--t-fast) var(--ease-out);
}
.file-card:hover .file-icon { transform: scale(1.05); }
.file-badges { display: flex; flex-wrap: wrap; gap: 4px; min-height: 20px; margin-bottom: 4px; }
.file-badge {
  display: inline-flex; align-items: center;
  min-width: 0; height: 20px; padding: 0 6px;
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  font-size: 11px; font-weight: var(--weight-semibold);
}
.file-badge.favorite { color: #b45309; background: #fef3c7; }
.file-badge.shared { color: var(--accent); background: var(--accent-soft); }
.file-name { font-size: var(--text-sm); font-weight: var(--weight-semibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
.file-meta { font-size: var(--text-xs); color: var(--fg-tertiary); margin-bottom: 6px; }
.file-owner { font-size: var(--text-xs); color: var(--fg-secondary); }
.file-members { display: flex; }
.file-members .avatar { border: 2px solid var(--bg-elevated); }
.file-members .avatar:not(:first-child) { margin-left: -6px; }
.file-card.upload { background: var(--bg-subtle); border: 2px dashed var(--border); display: flex; align-items: center; justify-content: center; }
.file-card.upload:hover { border-color: var(--accent); background: var(--accent-soft); }
.upload-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  aspect-ratio: 1; width: 100%;
  color: var(--fg-tertiary); font-size: var(--text-sm);
  gap: 6px; text-align: center; padding: var(--s-3);
  font-weight: var(--weight-medium);
}
.upload-zone svg { color: var(--fg-tertiary); transition: color var(--t-fast); }
.file-card.upload:hover .upload-zone, .file-card.upload:hover .upload-zone svg { color: var(--accent); }

.drive-detail-panel {
  border-left: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  min-width: 0;
  overflow-y: auto;
}
.drive-detail-head { display: flex; gap: var(--s-3); align-items: flex-start; min-width: 0; }
.drive-detail-icon {
  width: 48px; height: 48px; flex: 0 0 auto;
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--c);
  display: flex; align-items: center; justify-content: center;
}
.drive-detail-icon .lucide { width: 24px; height: 24px; }
.drive-detail-head h3 {
  margin: 2px 0 2px;
  min-width: 0;
  font-size: var(--text-lg);
  line-height: 1.25;
  max-width: 190px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.drive-detail-head p { margin: 0; color: var(--fg-secondary); font-size: var(--text-sm); }
.drive-detail-kicker { font-size: var(--text-xs); color: var(--fg-tertiary); font-weight: var(--weight-semibold); }
.drive-detail-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.drive-detail-actions .btn.active { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 36%, var(--border)); background: var(--accent-soft); }
.drive-detail-section { display: flex; flex-direction: column; gap: var(--s-2); }
.drive-detail-label { font-size: var(--text-xs); color: var(--fg-tertiary); font-weight: var(--weight-semibold); }
.drive-share-control { width: 100%; }
.drive-share-control .seg { flex: 1; justify-content: center; }
.drive-share-link {
  display: flex; align-items: center; gap: 6px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}
.drive-share-link span {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--text-xs); color: var(--fg-secondary);
}
.drive-share-link button {
  border: 0; background: transparent; color: var(--accent);
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  cursor: pointer;
}
.drive-reference-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--accent-soft) 38%, var(--bg-subtle));
}
.drive-reference-card > span {
  color: var(--fg);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.drive-reference-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.drive-reference-actions button {
  min-width: 0;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.drive-reference-actions button:hover {
  border-color: color-mix(in srgb, var(--accent) 46%, var(--border));
  color: var(--accent);
  background: #fff;
}
.drive-message-share-panel {
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border));
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--accent-soft) 34%, var(--bg-elevated));
}
.drive-message-channel-select,
.drive-message-share-panel textarea {
  width: 100%;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
}
.drive-message-channel-select {
  min-height: 34px;
  padding: 0 9px;
  font-size: var(--text-sm);
}
.drive-message-share-panel textarea {
  min-height: 74px;
  padding: 8px 9px;
  resize: vertical;
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}
.drive-message-share-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.drive-message-share-foot span,
.drive-share-empty {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
}
.drive-message-share-foot span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drive-message-share-foot .btn {
  flex-shrink: 0;
}
.drive-info-list { display: flex; flex-direction: column; gap: 10px; }
.drive-info-list div { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 8px; align-items: start; }
.drive-info-list span { color: var(--fg-tertiary); font-size: var(--text-xs); }
.drive-info-list strong {
  min-width: 0;
  color: var(--fg);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.drive-trash-list { display: flex; flex-direction: column; gap: 8px; }
.drive-trash-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}
.drive-trash-row span,
.drive-trash-more {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
}
.drive-trash-row strong {
  min-width: 0;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.drive-trash-more { padding: 2px 8px; }
.drive-move-select {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--fg);
  font: inherit;
  font-size: var(--text-sm);
}
.drive-move-select:hover {
  border-color: var(--border-strong);
}
.drive-move-select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.drive-detail-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-2); }
.drive-detail-summary div {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}
.drive-detail-summary span { display: block; font-size: var(--text-lg); font-weight: var(--weight-bold); }
.drive-detail-summary em { font-style: normal; font-size: var(--text-xs); color: var(--fg-tertiary); }
.drive-action-modal { width: min(460px, calc(100vw - 40px)); }
.drive-dialog-body { display: flex; flex-direction: column; gap: var(--s-3); }
.drive-dialog-desc { margin: 0; color: var(--fg-secondary); font-size: var(--text-sm); line-height: var(--leading-relaxed); }
.drive-dialog-desc[hidden] { display: none; }
.drive-dialog-field {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  color: var(--fg-secondary);
  font-size: var(--text-sm);
}
.drive-dialog-field[hidden] { display: none; }
.drive-dialog-field span { font-weight: var(--weight-medium); color: var(--fg); }
.drive-dialog-field textarea.input-wrap {
  width: 100%;
  min-height: 104px;
  resize: vertical;
}
.drive-dialog-warning {
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 34%, var(--border));
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--danger-soft) 46%, var(--bg-elevated));
  color: var(--danger-strong);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}
.drive-dialog-warning[hidden] { display: none; }
.drive-dialog-submit.danger {
  background: var(--danger);
  color: white;
}
.drive-dialog-submit.danger:hover { background: var(--danger-strong); }
.drive-note {
  width: 100%;
  min-height: 72px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  text-align: left;
  line-height: 1.5;
  cursor: pointer;
}
.drive-note:hover { border-color: var(--accent); color: var(--fg); }
.drive-danger-link {
  margin-top: auto;
  padding-top: var(--s-3);
  border: 0;
  border-top: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--fg-tertiary);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-align: left;
  cursor: pointer;
}
.drive-danger-link:hover { color: var(--danger); }

/* ============================================================
   Agents
   ============================================================ */
.agent-studio {
  margin-bottom: var(--s-6);
  padding: var(--s-5);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-elevated);
  box-shadow: none;
}
[data-theme="dark"] .agent-studio {
  background: var(--bg-elevated);
}
.agent-studio-main { max-width: 760px; margin-bottom: var(--s-4); }
.agent-studio-eyebrow { display: inline-flex; align-items: center; gap: 6px; margin-bottom: var(--s-2); padding: 3px 8px; border-radius: var(--r-full); background: var(--bg-elevated); border: 1px solid var(--border); color: var(--fg-secondary); font-size: var(--text-xs); font-weight: var(--weight-medium); }
.agent-studio h2 { font-size: var(--text-2xl); font-weight: var(--weight-bold); letter-spacing: -0.01em; margin-bottom: 6px; }
.agent-studio p { max-width: 680px; color: var(--fg-secondary); line-height: var(--leading-relaxed); font-size: var(--text-md); }
.agent-studio-actions { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-4); }
.agent-config-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3); margin-bottom: var(--s-4); }
.agent-config-card {
  min-width: 0;
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-1);
}
.agent-config-label { margin-bottom: var(--s-2); color: var(--fg-tertiary); font-size: var(--text-xs); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: 0.04em; }
.agent-model-select { display: flex; align-items: center; gap: 8px; margin-bottom: var(--s-2); }
.agent-model-select strong { display: block; font-size: var(--text-md); }
.agent-model-select span { display: block; color: var(--fg-tertiary); font-size: var(--text-xs); }
.model-dot { width: 10px; height: 10px; border-radius: var(--r-full); background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.model-options,
.skill-grid-mini { display: flex; flex-wrap: wrap; gap: 4px; }
.model-chip,
.skill-chip {
  padding: 3px 8px;
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}
.model-chip.active,
.skill-chip.active { background: var(--accent-soft); color: var(--accent); }
.skill-chip.add { border: 1px dashed var(--border-strong); background: transparent; }
.role-editor p { margin-top: 4px; color: var(--fg-secondary); font-size: var(--text-sm); line-height: var(--leading-snug); }
.permission-list { display: grid; gap: 6px; }
.permission-list label { display: flex; align-items: center; gap: 6px; color: var(--fg-secondary); font-size: var(--text-sm); }
.permission-list input { accent-color: var(--accent); }
.workflow-strip {
  display: grid;
  grid-template-columns: 1fr 28px 1fr 28px 1fr 28px 1fr;
  align-items: center;
  gap: 0;
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
}
.workflow-node { display: flex; align-items: center; gap: 8px; min-width: 0; }
.workflow-node span { width: 24px; height: 24px; border-radius: var(--r-full); display: flex; align-items: center; justify-content: center; background: var(--bg-subtle); color: var(--fg-secondary); font-size: var(--text-xs); font-weight: var(--weight-bold); }
.workflow-node.active span { background: var(--accent); color: var(--fg-on-accent); }
.workflow-node strong { display: block; font-size: var(--text-sm); }
.workflow-node em { display: block; color: var(--fg-tertiary); font-style: normal; font-size: var(--text-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workflow-line { height: 1px; background: var(--border-strong); margin: 0 6px; }
.agent-section { margin-bottom: var(--s-8); }
.agent-section-head { display: flex; align-items: baseline; gap: var(--s-3); margin-bottom: var(--s-4); }
.agent-section-head h3 { font-size: var(--text-lg); font-weight: var(--weight-bold); letter-spacing: -0.01em; }
.agent-section-sub { font-size: var(--text-sm); color: var(--fg-secondary); }
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: var(--s-3); }
.agent-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  transition: all var(--t-mid) var(--ease-out);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.agent-card::before {
  display: none;
}
.agent-card:hover { box-shadow: var(--shadow-2); border-color: var(--border-strong); }
.agent-card.mine { border-color: var(--accent); }
.agent-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-3); position: relative; }
.agent-avatar.large { width: 48px; height: 48px; background: linear-gradient(135deg, var(--a1), var(--a2)); border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; font-size: 22px; box-shadow: var(--shadow-2); position: relative; }
.agent-avatar.large::after { display: none; }
.agent-avatar.small { width: 24px; height: 24px; background: linear-gradient(135deg, var(--primary-500), var(--accent-purple)); border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; font-size: 12px; }
.agent-status-pill { display: flex; align-items: center; gap: 4px; padding: 3px 8px; background: var(--bg-subtle); border-radius: var(--r-full); font-size: var(--text-xs); color: var(--fg-secondary); font-weight: var(--weight-medium); }
.agent-card-name { font-size: var(--text-md); font-weight: var(--weight-semibold); margin-bottom: 4px; position: relative; }
.agent-card-desc { font-size: var(--text-sm); color: var(--fg-secondary); line-height: var(--leading-snug); margin-bottom: var(--s-3); min-height: 36px; position: relative; }
.agent-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-2);
  padding: var(--s-3) 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--s-3);
  position: relative;
}
.agent-stat { text-align: center; }
.agent-stat-num { font-size: var(--text-lg); font-weight: var(--weight-bold); letter-spacing: -0.01em; }
.agent-stat-label { font-size: 10px; color: var(--fg-tertiary); text-transform: uppercase; letter-spacing: 0.04em; }
.agent-capabilities { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: var(--s-3); position: relative; }
.cap { padding: 2px 8px; background: var(--bg-subtle); border-radius: var(--r-full); font-size: var(--text-xs); color: var(--fg); font-weight: var(--weight-medium); }

.agent-page { display: grid; gap: var(--s-3); }
.agent-page-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
}
.agent-page-identity { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.agent-pet-large,
.agent-mini-pet {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  font-size: 24px;
  flex-shrink: 0;
}
.agent-page .agent-pet-large { width: 40px; height: 40px; font-size: 20px; }
.agent-page-identity h2 { margin: 0 0 3px; font-size: var(--text-xl); letter-spacing: 0; }
.agent-page-identity p { margin: 0; max-width: none; font-size: var(--text-sm); color: var(--fg-secondary); }
.agent-page-actions,
.agent-bottom-actions,
.agent-mini-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--s-2); flex-wrap: wrap; }
.agent-page-actions[hidden] { display: none !important; }
.agent-type-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-2);
  padding: var(--s-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
}
.agent-type-tab {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px var(--s-2);
  align-items: center;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg-secondary);
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.agent-type-tab:hover {
  border-color: var(--border);
  background: var(--bg-subtle);
}
.agent-type-tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.agent-type-tab.active::before {
  content: "";
  position: absolute;
  inset: 8px auto 8px 0;
  width: 3px;
  border-radius: var(--r-full);
  background: var(--accent);
}
.agent-type-tab span,
.agent-type-tab strong,
.agent-type-tab em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-type-tab span {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
}
.agent-type-tab strong {
  justify-self: end;
  font-size: var(--text-lg);
}
.agent-type-tab em {
  grid-column: 1 / -1;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-style: normal;
}
.agent-type-tab.active em { color: var(--accent); }
.agent-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-3);
}
.agent-summary-item {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
}
.agent-summary-item span,
.agent-summary-item em {
  display: block;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-style: normal;
}
.agent-summary-item strong { display: block; margin: 3px 0; font-size: var(--text-lg); letter-spacing: 0; }
.agent-config-form { display: grid; gap: var(--s-4); }
.agent-console {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: var(--s-4);
  align-items: start;
}
.agent-section-nav {
  position: sticky;
  top: var(--s-4);
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: var(--s-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
}
.agent-section-tab {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg-secondary);
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.agent-section-tab:hover,
.agent-section-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.agent-section-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.agent-section-tab strong,
.agent-section-tab span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-section-tab strong { font-size: var(--text-sm); }
.agent-section-tab span {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
}
.agent-section-tab.active span { color: var(--accent); }
.agent-section-workspace {
  min-width: 0;
  display: grid;
  gap: var(--s-3);
}
.agent-section-panel { min-width: 0; }
.agent-section-panel[hidden] { display: none !important; }
.agent-section-panel.active {
  display: grid;
  gap: var(--s-4);
}
.agent-section-panel > .agent-panel,
.agent-section-panel > .agent-registry-panel { width: 100%; }
.agent-config-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.92fr) minmax(360px, 1.08fr);
  gap: var(--s-4);
}
.agent-panel {
  min-width: 0;
  padding: var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
}
.agent-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}
.agent-panel-head h3 { margin: 0; font-size: var(--text-lg); font-weight: var(--weight-bold); letter-spacing: -0.01em; }
.agent-panel-head span { color: var(--fg-tertiary); font-size: var(--text-sm); text-align: right; }
.agent-panel-head.compact { margin-bottom: var(--s-2); }
.agent-panel-head.compact h3 { font-size: var(--text-md); }
.agent-registry-panel { display: grid; gap: var(--s-3); }
.agent-registry-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-2);
}
.agent-registry-summary div {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
}
.agent-registry-summary span,
.agent-registry-card-head span,
.agent-registry-card-head em,
.agent-memory-row em {
  display: block;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-style: normal;
}
.agent-registry-summary strong { display: block; margin-top: 3px; font-size: var(--text-lg); }
.agent-registry-focus {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
}
.agent-registry-focus strong,
.agent-registry-focus span { display: block; }
.agent-registry-focus strong { font-size: var(--text-md); }
.agent-registry-focus span {
  margin-top: 2px;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
}
.agent-registry-focus em {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: var(--text-sm);
  font-style: normal;
  font-weight: var(--weight-bold);
}
.agent-registry-focus[hidden],
.agent-registry-grid[hidden],
.agent-registry-type-panel[hidden] { display: none !important; }
.agent-registry-type-panels,
.agent-registry-type-panel.active {
  display: grid;
  gap: var(--s-3);
}
.agent-create-row {
  display: grid;
  grid-template-columns: minmax(160px, 0.8fr) minmax(220px, 1.2fr) minmax(130px, 0.7fr) auto auto;
  gap: var(--s-2);
  align-items: center;
}
.agent-registry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--s-3);
}
.agent-registry-card {
  min-width: 0;
  display: grid;
  gap: var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}
.agent-registry-card-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--s-3);
  align-items: center;
}
.agent-registry-avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}
.agent-registry-card-head strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-md);
}
.agent-registry-card p {
  margin: 0;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  line-height: 1.55;
}
.agent-registry-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-2);
}
.agent-registry-stats span {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
}
.agent-registry-stats strong {
  margin-right: 4px;
  color: var(--fg);
  font-size: var(--text-sm);
}
.agent-registry-chips,
.agent-registry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.agent-registry-card-tools {
  display: flex;
  justify-content: flex-start;
}
.agent-scope-picker {
  display: grid;
  gap: 6px;
}
.agent-scope-picker span {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.btn.danger,
.icon-btn.danger {
  color: var(--danger);
}
.btn.danger:hover,
.icon-btn.danger:hover {
  border-color: var(--danger);
  background: var(--danger-soft);
}
.agent-registry-chips em {
  padding: 3px 8px;
  border-radius: var(--r-full);
  background: var(--bg-elevated);
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-style: normal;
}
.agent-registry-bottom {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
}
.agent-memory-list { display: grid; gap: var(--s-2); }
.agent-memory-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: var(--s-2);
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
}
.agent-memory-row > span {
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.agent-memory-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-sm);
}
.agent-form-grid,
.agent-workflow-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
}
.agent-field { display: grid; gap: 6px; min-width: 0; }
.agent-field.wide,
.agent-field.compact.wide { grid-column: 1 / -1; }
.agent-field > span,
.agent-onboarding-grid label > span {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.agent-field.compact textarea { min-height: 64px; resize: vertical; }
.agent-skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--s-3);
}
.agent-skill-card,
.agent-workflow-card,
.agent-permission-group {
  min-width: 0;
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}
.agent-skill-top,
.agent-workflow-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}
.agent-toggle-line { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: var(--weight-semibold); }
.agent-toggle-line span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-toggle-line input,
.agent-permission-list input { accent-color: var(--accent); }
.agent-add-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.4fr) auto;
  gap: var(--s-2);
  align-items: center;
  margin-top: var(--s-3);
}
.agent-workflow-list { display: grid; gap: var(--s-3); }
.agent-workflow-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--s-2);
  margin-top: var(--s-3);
}
.agent-workflow-step {
  display: flex;
  gap: 8px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
}
.agent-workflow-step > span {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}
.agent-workflow-step strong,
.agent-workflow-step em { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-workflow-step strong { font-size: var(--text-sm); }
.agent-workflow-step em { color: var(--fg-tertiary); font-size: var(--text-xs); font-style: normal; }
.agent-permission-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-3);
}
.agent-permission-group h4 { margin: 0 0 4px; font-size: var(--text-md); }
.agent-permission-group p { margin: 0 0 var(--s-3); max-width: none; color: var(--fg-secondary); font-size: var(--text-sm); }
.agent-permission-list { display: grid; gap: 8px; }
.agent-permission-list label { display: flex; align-items: center; gap: 8px; font-size: var(--text-sm); color: var(--fg); }
.agent-bottom-actions {
  padding: var(--s-3) 0 0;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
}
.agent-mini-panel { display: grid; gap: var(--s-3); }
.agent-mini-status { display: flex; align-items: center; gap: var(--s-3); }
.agent-mini-status strong { display: block; }
.agent-mini-status p,
.agent-mini-section p { margin: 2px 0 0; color: var(--fg-secondary); font-size: var(--text-sm); }
.agent-mini-section { display: grid; gap: 6px; }
.agent-mini-section > span { color: var(--fg-tertiary); font-size: var(--text-xs); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: 0.04em; }
.agent-mini-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.agent-mini-chips em {
  padding: 3px 8px;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--text-xs);
  font-style: normal;
  font-weight: var(--weight-medium);
}
.agent-mini-flow {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
}
.agent-mini-flow strong,
.agent-mini-flow small { display: block; }
.agent-mini-flow small { margin-top: 2px; color: var(--fg-tertiary); }
.agent-run-card {
  display: grid;
  gap: var(--s-2);
  min-width: 0;
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
}
.agent-run-card.is-failed { border-color: rgba(239, 68, 68, 0.28); }
.agent-run-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}
.agent-run-card-head strong {
  min-width: 0;
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.agent-run-card-head span {
  flex: 0 0 auto;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
}
.agent-run-card-body {
  color: var(--fg);
  font-size: var(--text-sm);
  line-height: 1.65;
}
.agent-run-heading {
  display: block;
  margin: 8px 0 4px;
  font-size: var(--text-sm);
}
.agent-run-bullet {
  color: var(--accent);
  font-weight: var(--weight-bold);
}
.agent-empty-note {
  margin: 0;
  color: var(--fg-tertiary);
  font-size: var(--text-sm);
}
.agent-conv-actions { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.agent-conv-msg-avatar { display: grid; place-items: center; }

@media (max-width: 1180px) {
  .agent-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .agent-console { grid-template-columns: 1fr; }
  .agent-section-nav {
    position: static;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .agent-config-layout,
  .agent-permission-grid,
  .agent-registry-bottom { grid-template-columns: 1fr; }
  .agent-create-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .agent-page-hero,
  .agent-page-identity,
  .agent-panel-head { align-items: flex-start; flex-direction: column; }
  .agent-page-actions,
  .agent-bottom-actions { justify-content: flex-start; }
  .agent-summary-grid,
  .agent-type-switch,
  .agent-section-nav,
  .agent-registry-summary,
  .agent-form-grid,
  .agent-workflow-fields,
  .agent-add-row,
  .agent-create-row { grid-template-columns: 1fr; }
}

/* ============================================================
   Knowledge
   ============================================================ */
.kb-search-hero {
  text-align: center;
  padding: var(--s-12) var(--s-6);
  background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--accent-soft) 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  margin-bottom: var(--s-6);
  position: relative;
  overflow: hidden;
}
.kb-search-hero::before {
  content: '';
  position: absolute; top: -100px; right: -100px;
  width: 300px; height: 300px;
  background: radial-gradient(circle, oklch(0.7 0.2 280 / 0.2), transparent);
  filter: blur(60px);
  pointer-events: none;
}
.kb-search-icon { font-size: 32px; margin-bottom: var(--s-3); }
.kb-search-hero h2 { font-family: var(--font-display); font-size: 32px; font-weight: var(--weight-bold); margin-bottom: 6px; letter-spacing: -0.02em; }
.kb-search-hero p { color: var(--fg-secondary); margin-bottom: var(--s-5); font-size: var(--text-md); }
.kb-search-bar {
  display: flex; align-items: center; gap: 8px;
  max-width: 600px;
  margin: 0 auto var(--s-4);
  padding: 6px 6px 6px var(--s-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-3);
  position: relative;
}
.kb-search-bar:focus-within { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.kb-search-bar input { flex: 1; font-size: var(--text-md); padding: 8px 0; }
.kb-suggestions { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; font-size: var(--text-sm); color: var(--fg-tertiary); }
.kb-chip {
  padding: 4px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-size: var(--text-sm);
  transition: all var(--t-fast) var(--ease-out);
  font-weight: var(--weight-medium);
}
.kb-chip:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.kb-section h3 { font-size: var(--text-lg); font-weight: var(--weight-bold); margin-bottom: var(--s-3); }
.kb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s-3); }
.kb-card {
  display: flex; gap: var(--s-3);
  padding: var(--s-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: all var(--t-mid) var(--ease-out);
}
.kb-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-3); border-color: var(--accent); }
.kb-card.add { display: flex; align-items: center; justify-content: center; min-height: 100px; background: var(--bg-subtle); border: 2px dashed var(--border); cursor: pointer; flex-direction: column; }
.kb-card.add:hover { border-color: var(--accent); background: var(--accent-soft); }
.kb-add-inner { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--fg-tertiary); font-size: var(--text-sm); font-weight: var(--weight-medium); }
.kb-card-icon { width: 40px; height: 40px; background: var(--g); border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; color: white; font-size: 18px; flex-shrink: 0; box-shadow: var(--shadow-1); }
.kb-card-body { flex: 1; min-width: 0; }
.kb-card-name { font-size: var(--text-md); font-weight: var(--weight-semibold); margin-bottom: 2px; }
.kb-card-desc { font-size: var(--text-sm); color: var(--fg-secondary); margin-bottom: 6px; }
.kb-card-meta { font-size: var(--text-xs); color: var(--fg-tertiary); }

.knowledge-search-panel {
  text-align: left;
  padding: var(--s-4);
  background: var(--bg-elevated);
  border-radius: var(--r-lg);
  box-shadow: none;
}
.knowledge-search-panel::before { display: none; }
.knowledge-search-panel .kb-search-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--s-3);
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: var(--r-md);
}
.knowledge-search-panel .kb-search-icon .lucide { width: 18px; height: 18px; }
.knowledge-search-panel h2 {
  font-family: var(--font-sans);
  font-size: var(--text-xl);
  letter-spacing: 0;
}
.knowledge-search-panel p {
  max-width: 720px;
  margin-bottom: var(--s-4);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}
.knowledge-search-panel .kb-search-bar {
  max-width: none;
  margin: 0 0 var(--s-3);
  border-radius: var(--r-lg);
  box-shadow: none;
}
.knowledge-search-panel .kb-suggestions { justify-content: flex-start; }

.knowledge-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: var(--s-4);
  align-items: start;
}
.knowledge-main,
.knowledge-side {
  min-width: 0;
  display: grid;
  gap: var(--s-4);
}
.knowledge-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
}
.knowledge-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}
.knowledge-panel-head h3 {
  margin: 0;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  letter-spacing: 0;
}
.knowledge-panel-head span {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  text-align: right;
}
.knowledge-field {
  display: grid;
  gap: 6px;
  margin-bottom: var(--s-3);
}
.knowledge-field span {
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}

button.kb-card {
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
}
.knowledge-base-card.active {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.knowledge-base-card .kb-card-desc,
.knowledge-base-card .kb-card-meta {
  display: block;
}
.knowledge-detail-desc {
  margin: 0 0 var(--s-3);
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}
.knowledge-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}
.knowledge-doc-panel { min-height: 220px; }
.knowledge-doc-list {
  display: grid;
  gap: var(--s-2);
}
.knowledge-doc-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--s-3);
  padding: var(--s-3);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
}
.knowledge-doc-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
}
.knowledge-doc-icon .lucide { width: 18px; height: 18px; }
.knowledge-doc-body { min-width: 0; }
.knowledge-doc-body strong {
  display: block;
  margin-bottom: 4px;
  font-size: var(--text-sm);
}
.knowledge-doc-body p {
  margin: 0 0 var(--s-2);
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.knowledge-doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.knowledge-doc-meta span {
  padding: 2px 7px;
  color: var(--fg-tertiary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-full);
  font-size: 11px;
}

@media (max-width: 1100px) {
  .knowledge-workspace { grid-template-columns: 1fr; }
  .knowledge-side { grid-row: auto; }
}

@media (max-width: 640px) {
  .knowledge-search-panel,
  .knowledge-panel { padding: var(--s-3); }
  .knowledge-panel-head { flex-direction: column; }
  .knowledge-panel-head span { text-align: left; }
  .knowledge-doc-row { grid-template-columns: 32px minmax(0, 1fr); }
  .knowledge-doc-row .icon-btn { grid-column: 2; justify-self: start; }
}

/* ============================================================
   Reports
   ============================================================ */
.report-progress {
  padding: var(--s-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: var(--s-4);
}
.report-progress-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: var(--text-md); font-weight: var(--weight-semibold); }
.report-progress-pct { font-weight: var(--weight-bold); color: var(--accent); }
.report-progress-bar { height: 8px; background: var(--bg-subtle); border-radius: var(--r-full); overflow: hidden; margin-bottom: var(--s-3); }
.report-progress-bar > div { height: 100%; background: linear-gradient(90deg, var(--primary-500), var(--accent-purple)); border-radius: var(--r-full); transition: width 1s var(--ease-out); }
.report-avatars { display: flex; }
.report-avatars .avatar { border: 2px solid var(--bg-elevated); margin-left: -8px; position: relative; transition: transform var(--t-fast) var(--ease-out); }
.report-avatars .avatar:first-child { margin-left: 0; }
.report-avatars .avatar:hover { transform: translateY(-2px); z-index: 1; }
/* R7 Fix: ✓ → SVG check icon */
.report-avatars .avatar.submitted::after { content: ''; position: absolute; bottom: -2px; right: -2px; width: 14px; height: 14px; background: var(--accent-emerald); border: 2px solid var(--bg-elevated); border-radius: 50%; }
.report-avatars .avatar.submitted > .avatar-check-icon { position: absolute; bottom: 1px; right: 1px; width: 8px; height: 8px; color: white; z-index: 1; pointer-events: none; }
.report-avatars .avatar.pending { opacity: 0.4; }

.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--s-3); }
.report-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  transition: all var(--t-fast) var(--ease-out);
}
.report-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.report-card.ai-summary { background: linear-gradient(135deg, var(--accent-soft) 0%, var(--bg-elevated) 60%); border-color: var(--accent); }
.report-card.pending { opacity: 0.7; }
.report-card.report-editor { grid-row: span 2; border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.report-card-icon { font-size: 24px; margin-bottom: var(--s-2); }
.report-card h3 { font-size: var(--text-md); font-weight: var(--weight-semibold); margin-bottom: 4px; }
.report-card.ai-summary p { font-size: var(--text-sm); color: var(--fg-secondary); margin-bottom: var(--s-3); }
.report-summary-kpis { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--s-3); }
.report-summary-kpis span { padding: 4px 8px; background: var(--bg-subtle); border-radius: var(--r-full); font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--fg-secondary); }
.report-export-note {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-2);
  margin-top: var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: color-mix(in oklab, var(--bg-elevated) 74%, var(--bg-subtle));
}
.report-export-note.empty {
  grid-template-columns: 1fr;
  border-style: dashed;
}
.report-export-note span {
  min-width: 0;
}
.report-export-note strong {
  display: block;
  overflow: hidden;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.report-export-note em {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.report-export-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.report-ai-list { font-size: var(--text-sm); line-height: 1.8; margin-bottom: var(--s-3); }
.report-ai-list li { padding: 4px 0; }
.report-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-3); }
.report-author { display: flex; align-items: center; gap: 8px; }
.report-author-name { font-size: var(--text-md); font-weight: var(--weight-semibold); }
.report-author-meta { font-size: var(--text-xs); color: var(--fg-tertiary); }
.report-content { margin-bottom: var(--s-3); }
.report-section { margin-bottom: var(--s-3); }
.report-section-title { font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--fg-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.report-content ul { font-size: var(--text-sm); color: var(--fg); line-height: var(--leading-relaxed); padding-left: 16px; list-style: disc; }
.report-content ul li { margin-bottom: 2px; }
.report-card-foot { display: flex; gap: var(--s-3); font-size: var(--text-sm); color: var(--fg-secondary); padding-top: var(--s-3); border-top: 1px solid var(--border-subtle); }
.report-empty { padding: var(--s-6); text-align: center; color: var(--fg-tertiary); font-size: var(--text-sm); margin-bottom: var(--s-3); }
.report-reminder-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin: calc(var(--s-3) * -0.35) 0 var(--s-3);
  padding: 8px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: color-mix(in oklab, var(--warning-soft) 28%, var(--bg-elevated));
  color: var(--fg-secondary);
  font-size: var(--text-xs);
}
.report-reminder-note span {
  color: var(--fg-tertiary);
}
.report-reminder-note strong {
  overflow: hidden;
  color: var(--fg);
  font-weight: var(--weight-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.report-sync-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3);
  margin-bottom: var(--s-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}
.report-sync-copy {
  min-width: 0;
}
.report-sync-copy strong {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--fg);
  margin-bottom: 2px;
}
.report-sync-copy span {
  display: block;
  font-size: var(--text-xs);
  color: var(--fg-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.report-sync-strip .btn {
  flex-shrink: 0;
}
.report-quality-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-3);
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}
.report-quality-strip.good {
  border-color: color-mix(in srgb, var(--success) 34%, var(--border));
  background: color-mix(in srgb, var(--success-soft) 42%, var(--bg-subtle));
}
.report-quality-strip.warn {
  border-color: color-mix(in srgb, var(--warning) 40%, var(--border));
  background: color-mix(in srgb, var(--warning-soft) 42%, var(--bg-subtle));
}
.report-quality-main {
  min-width: 0;
}
.report-quality-main strong {
  display: block;
  color: var(--fg);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  margin-bottom: 2px;
}
.report-quality-main span {
  display: block;
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.report-quality-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.report-quality-chips span {
  padding: 4px 7px;
  border-radius: var(--r-full);
  background: var(--bg-elevated);
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}
.report-form { display: flex; flex-direction: column; gap: var(--s-3); }
.report-form label { display: flex; flex-direction: column; gap: 6px; font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--fg-secondary); }
.report-textarea {
  width: 100%;
  resize: vertical;
  min-height: 72px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  line-height: var(--leading-relaxed);
}
.report-textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.report-card-actions { display: flex; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--border-subtle); }
.report-card-actions [data-report-copy-draft] { margin-right: auto; }
.report-message-share-panel {
  margin-top: var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: color-mix(in oklab, var(--bg-elevated) 72%, var(--bg-subtle));
}
.report-message-share-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}
.report-message-share-head strong {
  color: var(--fg);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.report-message-share-head span {
  overflow: hidden;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.report-message-share-grid {
  display: grid;
  grid-template-columns: minmax(150px, .7fr) minmax(0, 1.3fr);
  gap: var(--s-3);
}
.report-message-share-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.report-message-share-grid select,
.report-message-share-grid textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: var(--text-sm);
}
.report-message-share-grid select {
  height: 34px;
  padding: 0 9px;
}
.report-message-share-grid textarea {
  min-height: 72px;
  padding: 9px 10px;
  resize: vertical;
  line-height: var(--leading-relaxed);
}
.report-message-share-grid select:focus,
.report-message-share-grid textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.report-message-share-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--border-subtle);
}
.report-message-share-foot span {
  overflow: hidden;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   AI Panel (right)
   ============================================================ */
.ai-panel[hidden],
.ai-fab[hidden] {
  display: none !important;
}

.ai-panel {
  position: fixed;
  top: var(--s-4);
  right: var(--s-4);
  bottom: var(--s-4);
  z-index: 1180;
  width: min(var(--ai-w), calc(100vw - var(--s-8)));
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-5);
  display: flex;
  flex-direction: column;
  transform: translateX(calc(100% + var(--s-6)));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    transform var(--t-slow) var(--ease-emph),
    opacity var(--t-mid) var(--ease-out),
    visibility var(--t-mid) var(--ease-out);
}
.ai-panel.open {
  transform: translateX(0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.ai-panel-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border-subtle); }
.ai-panel-title { display: flex; align-items: center; gap: 8px; }
.ai-panel-title > div > div:first-child { font-size: var(--text-md); font-weight: var(--weight-semibold); }
.ai-panel-sub { font-size: var(--text-xs); color: var(--fg-tertiary); }
.ai-panel-actions { display: flex; align-items: center; gap: 4px; }
.ai-panel-body { flex: 1; overflow-y: auto; padding: var(--s-3); display: flex; flex-direction: column; gap: var(--s-3); }
.ai-msg { display: flex; gap: 8px; max-width: 92%; }
.ai-msg.from-user { margin-left: auto; flex-direction: row-reverse; }
.ai-msg-avatar { width: 24px; height: 24px; background: linear-gradient(135deg, var(--primary-500), var(--accent-purple)); border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; font-size: 11px; flex-shrink: 0; color: white; }
.ai-msg-bubble {
  padding: 9px 12px;
  background: var(--bg-subtle);
  border-radius: var(--r-lg);
  border-top-left-radius: var(--r-xs);
  font-size: var(--text-sm); line-height: var(--leading-relaxed);
}
.ai-msg-bubble.mine { background: var(--accent); color: var(--fg-on-accent); border-top-left-radius: var(--r-lg); border-top-right-radius: var(--r-xs); }
.ai-suggestion-card {
  margin-top: 8px;
  padding: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.ai-sug-title { font-size: var(--text-sm); font-weight: var(--weight-semibold); margin-bottom: 2px; }
.ai-sug-meta { font-size: var(--text-xs); color: var(--fg-secondary); margin-bottom: 6px; }
.ai-task-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.ai-task { display: flex; align-items: center; gap: 8px; padding: 6px; background: var(--bg-elevated); border-radius: var(--r-sm); border: 1px solid var(--border); }
.ai-task-dot { width: 6px; height: 6px; background: var(--c); border-radius: 50%; flex-shrink: 0; }
.ai-task-name { font-size: var(--text-sm); font-weight: var(--weight-medium); flex: 1; }
.ai-task-meta { font-size: var(--text-xs); color: var(--fg-tertiary); }
.ai-panel-input { display: flex; align-items: flex-end; gap: 4px; padding: var(--s-3); border-top: 1px solid var(--border-subtle); }
.ai-panel-input textarea { flex: 1; padding: 9px 6px; font-size: var(--text-sm); line-height: 1.5; resize: none; min-height: 48px; max-height: 160px; overflow-y: hidden; color: var(--fg); }
.ai-fab {
  position: fixed;
  right: var(--s-6);
  bottom: var(--s-6);
  z-index: 1170;
  width: 48px;
  height: 48px;
  border-radius: var(--r-lg);
  background: var(--bg-elevated);
  color: var(--accent);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-4);
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition:
    transform var(--t-mid) var(--ease-out),
    box-shadow var(--t-mid) var(--ease-out),
    border-color var(--t-mid) var(--ease-out),
    opacity var(--t-fast) var(--ease-out);
}
.ai-fab:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-5); }
.ai-fab.is-dragging,
.ai-fab.is-dragging:hover {
  cursor: grabbing;
  transform: none;
  transition: box-shadow var(--t-fast) var(--ease-out), opacity var(--t-fast) var(--ease-out);
}
.ai-fab:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--bg-elevated), 0 0 0 6px var(--accent); }
.ai-fab svg { width: 20px; height: 20px; }
.ai-pet-avatar {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, oklch(0.94 0.05 260), oklch(0.96 0.06 325));
  font-size: 20px;
  line-height: 1;
  box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.62);
}
.ai-fab::after {
  content: attr(data-agent-label);
  position: absolute;
  right: calc(100% + var(--s-3));
  top: 50%;
  transform: translate(6px, -50%);
  padding: 6px 10px;
  border-radius: var(--r-md);
  background: var(--bg-inverse);
  color: var(--fg-inverse);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  box-shadow: var(--shadow-3);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
.ai-fab:hover::after,
.ai-fab:focus-visible::after { opacity: 1; transform: translate(0, -50%); }
.ai-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-full);
  background: var(--danger);
  color: white;
  border: 2px solid var(--bg-elevated);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  line-height: 14px;
}
.ai-fab.is-hidden {
  transform: translateY(8px) scale(0.96);
  opacity: 0;
  pointer-events: none;
}

.agent-onboarding-modal {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--s-6);
  background: oklch(0.18 0.02 260 / 0.38);
}
.agent-onboarding-modal.open { display: flex; }
.agent-onboarding-dialog {
  width: min(760px, calc(100vw - 48px));
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-5);
}
.agent-onboarding-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-6);
  border-bottom: 1px solid var(--border-subtle);
}
.agent-onboarding-kicker {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.agent-onboarding-head h2 {
  margin: 0 0 6px;
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
}
.agent-onboarding-head p {
  max-width: 560px;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}
.agent-onboarding-form { padding: var(--s-6); }
.pet-option-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-3);
  margin-bottom: var(--s-5);
}
.pet-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s-2);
  min-height: 148px;
  padding: var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-elevated);
  text-align: left;
  transition: border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
.pet-option:hover { transform: translateY(-1px); border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.pet-option.active { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.pet-option-icon {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-lg);
  background: var(--bg-subtle);
  font-size: 25px;
}
.pet-option-body strong {
  display: block;
  margin-bottom: 4px;
  color: var(--fg);
  font-size: var(--text-md);
}
.pet-option-body span {
  display: block;
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
}
.agent-onboarding-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-4);
  margin-bottom: var(--s-4);
}
.agent-onboarding-grid label > span {
  display: block;
  margin-bottom: 6px;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.agent-onboarding-grid .input-wrap {
  width: 100%;
  min-height: 42px;
}
.agent-skill-picker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  padding: var(--s-3);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
}
.agent-skill-picker label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border-radius: var(--r-full);
  background: var(--bg-elevated);
  color: var(--fg-secondary);
  font-size: var(--text-sm);
}
.agent-skill-picker input { accent-color: var(--accent); }
.agent-onboarding-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
  margin-top: var(--s-5);
}

/* ============================================================
   Settings Page v2
   ============================================================ */
.settings-shell { display: grid; grid-template-columns: 220px 1fr; gap: var(--s-6); }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; }
.settings-nav-section { font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--fg-tertiary); text-transform: uppercase; letter-spacing: 0.04em; padding: var(--s-3) var(--s-3) 6px; }
.settings-nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  border-radius: var(--r-md);
  font-size: var(--text-md);
  color: var(--fg-secondary);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-out);
  font-weight: var(--weight-medium);
}
.settings-nav-item:hover { background: var(--bg-subtle); color: var(--fg); }
.settings-nav-item.active { background: var(--accent-soft); color: var(--accent); }
.settings-content { display: flex; flex-direction: column; gap: var(--s-4); max-width: 720px; }
.settings-section {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
}
.settings-section h3 { font-size: var(--text-lg); font-weight: var(--weight-semibold); margin-bottom: 4px; letter-spacing: -0.01em; }
.settings-section-desc { font-size: var(--text-sm); color: var(--fg-secondary); margin-bottom: var(--s-4); }
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--border-subtle);
  gap: var(--s-4);
}
.settings-row:last-child { border-bottom: none; }
.settings-row-body { flex: 1; min-width: 0; }
.settings-row-title { font-size: var(--text-md); font-weight: var(--weight-medium); margin-bottom: 2px; }
.settings-row-desc { font-size: var(--text-sm); color: var(--fg-secondary); }

.shortcut-overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-3);
}
.shortcut-overview-grid div {
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}
.shortcut-overview-grid strong {
  display: block;
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  margin-bottom: 2px;
}
.shortcut-overview-grid span {
  color: var(--fg-secondary);
  font-size: var(--text-sm);
}
.notification-overview-grid strong {
  font-size: var(--text-xl);
}
.notification-settings-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.notification-settings-row {
  align-items: center;
}
.notification-settings-row.is-muted .settings-row-title,
.notification-settings-row.is-muted .settings-row-desc {
  color: var(--fg-tertiary);
}
.notification-settings-row .status-pill {
  flex: 0 0 auto;
  white-space: nowrap;
}
.appearance-overview-grid strong {
  font-size: var(--text-xl);
}
.appearance-theme-control {
  width: max-content;
  margin-bottom: var(--s-3);
}
.appearance-theme-control .seg {
  min-width: 92px;
}
.appearance-option-copy {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-3);
}
.appearance-option-copy div {
  padding: var(--s-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}
.appearance-option-copy div.active {
  border-color: color-mix(in oklab, var(--accent) 38%, var(--border));
  background: var(--accent-soft);
}
.appearance-option-copy strong,
.appearance-option-copy span {
  display: block;
}
.appearance-option-copy strong {
  margin-bottom: 4px;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.appearance-option-copy span {
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
}
.appearance-swatch-row {
  padding-top: 2px;
}
.shortcut-settings-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.shortcut-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  min-height: 58px;
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--border-subtle);
}
.shortcut-setting-row:last-child { border-bottom: 0; }
.shortcut-setting-copy {
  flex: 1;
  min-width: 0;
}
.shortcut-setting-copy strong {
  display: block;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  margin-bottom: 2px;
}
.shortcut-setting-copy span {
  color: var(--fg-secondary);
  font-size: var(--text-sm);
}
.shortcut-setting-controls {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-shrink: 0;
}
.shortcut-input {
  width: 150px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-align: center;
}
.shortcut-input:focus {
  outline: 2px solid var(--accent-soft-strong);
  border-color: var(--accent);
}
.shortcut-setting-row.is-conflict .shortcut-input {
  border-color: color-mix(in oklab, var(--danger) 46%, var(--border));
  background: color-mix(in oklab, var(--danger) 7%, var(--bg-elevated));
}
.shortcut-actions-section .settings-actions {
  justify-content: flex-end;
}

/* Toggle Switch */
.toggle {
  position: relative;
  width: 36px; height: 20px;
  padding: 0;
  border: 0;
  background: var(--bg-muted);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: all var(--t-mid) var(--ease-out);
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: var(--bg-elevated);
  border-radius: 50%;
  transition: all var(--t-mid) var(--ease-out);
  box-shadow: var(--shadow-1);
}
.toggle.on { background: var(--accent); }
.toggle.on::after { transform: translateX(16px); }

.template-settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: var(--s-3); }
.template-setting-card {
  min-height: 146px;
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-raised);
  text-align: left;
}
.template-setting-card.active { background: var(--bg-elevated); }
.template-setting-card.add {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  border: 1px dashed var(--border-strong);
  color: var(--fg-secondary);
  transition: all var(--t-fast) var(--ease-out);
}
.template-setting-card.add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.template-setting-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-3); }
.template-setting-icon { width: 30px; height: 30px; border-radius: var(--r-md); background: color-mix(in oklab, var(--c) 14%, white); color: var(--c); display: flex; align-items: center; justify-content: center; }
.template-setting-card strong { display: block; margin-bottom: 4px; font-size: var(--text-md); }
.template-setting-card p { color: var(--fg-secondary); font-size: var(--text-sm); line-height: var(--leading-snug); margin-bottom: 8px; }
.template-setting-card span:not(.template-setting-icon) { color: var(--fg-tertiary); font-size: var(--text-xs); }
.template-setting-card.is-disabled { opacity: 0.68; background: var(--bg-subtle); }
.template-setting-card.is-busy { cursor: wait; opacity: .78; }
.template-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.template-field span { color: var(--fg-tertiary); font-size: var(--text-xs); font-weight: var(--weight-medium); }
.template-field input,
.template-field select,
.template-field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
  color: var(--fg);
  font-size: var(--text-sm);
  padding: 7px 8px;
}
.template-field textarea { resize: vertical; min-height: 72px; line-height: var(--leading-snug); }
.template-card-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); margin-top: var(--s-2); }
.template-card-actions span { color: var(--fg-tertiary); font-size: var(--text-xs); }
.template-card-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  opacity: .58;
  transition: opacity var(--t-fast) var(--ease-out);
}
.template-setting-card:hover .template-card-tools,
.template-setting-card:focus-within .template-card-tools { opacity: 1; }
.template-tool-btn {
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.template-tool-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.template-tool-btn:disabled { cursor: default; opacity: .42; }
.template-tool-btn.danger:hover:not(:disabled) {
  border-color: color-mix(in oklab, var(--danger) 34%, var(--border));
  color: var(--danger);
  background: color-mix(in oklab, var(--danger) 8%, var(--bg-elevated));
}
.template-tool-btn.danger { color: var(--fg-tertiary); }
.template-delete-confirm {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid color-mix(in oklab, var(--danger) 24%, var(--border));
  border-radius: var(--r-sm);
  background: color-mix(in oklab, var(--danger) 7%, var(--bg-elevated));
}
.template-delete-confirm span {
  flex: 1;
  min-width: 0;
  color: var(--fg-secondary);
}
.template-enable-pill {
  padding: 3px 8px;
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.template-enable-pill.on { background: var(--accent-soft); color: var(--accent); }
.template-create-card { min-height: 0; justify-content: flex-start; }

.settings-shell[data-enhanced="true"] {
  grid-template-columns: 232px minmax(0, 980px);
  align-items: start;
}
.settings-shell[data-enhanced="true"] .settings-nav {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-1);
}
.settings-nav-group + .settings-nav-group { margin-top: var(--s-2); }
button.settings-nav-item {
  width: 100%;
  text-align: left;
  border: 0;
}
.settings-nav-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.settings-content {
  max-width: 980px;
  min-width: 0;
}
.settings-content-head {
  padding: var(--s-1) 0 var(--s-2);
}
.settings-kicker {
  display: inline-flex;
  align-items: center;
  margin-bottom: 6px;
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.settings-content-head h2 {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.settings-content-head p {
  max-width: 680px;
  color: var(--fg-secondary);
  font-size: var(--text-md);
  line-height: var(--leading-relaxed);
}
.settings-panel {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.settings-panel[hidden] { display: none; }
.settings-profile-card {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-5);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg-raised));
  box-shadow: var(--shadow-1);
}
.settings-profile-form {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.settings-profile-main {
  flex: 1;
  min-width: 0;
}
.settings-profile-main strong {
  display: block;
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  margin-bottom: 2px;
}
.settings-profile-main span,
.settings-profile-main p {
  color: var(--fg-secondary);
  font-size: var(--text-sm);
}
.settings-profile-main p { margin-top: 6px; }
.settings-avatar-editor {
  display: flex;
  align-items: flex-end;
  gap: var(--s-2);
  flex-wrap: wrap;
  justify-content: flex-end;
}
.settings-avatar-editor label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}
.avatar-initials-input {
  width: 72px;
  text-align: center;
  text-transform: uppercase;
  font-weight: var(--weight-semibold);
}
.settings-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-3);
}
.settings-mini-card {
  min-width: 0;
  padding: var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-1);
}
.settings-mini-card > * {
  min-width: 0;
}
.settings-mini-card span,
.settings-mini-card em {
  display: block;
  margin-bottom: 6px;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-style: normal;
}
.settings-mini-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.settings-mini-card p {
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  overflow-wrap: anywhere;
}
.storage-card-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.security-card-grid {
  grid-template-columns: 1.15fr repeat(2, minmax(0, 1fr));
}
.storage-metric-card strong {
  font-size: var(--text-xl);
  line-height: 1.3;
}
.security-metric-card strong {
  font-size: var(--text-xl);
}
.storage-metric-card p.success {
  color: var(--success);
}
.security-metric-card.success {
  border-color: color-mix(in oklab, var(--success) 28%, var(--border));
  background: color-mix(in oklab, var(--success-soft) 36%, var(--bg-elevated));
}
.security-metric-card.warning {
  border-color: color-mix(in oklab, var(--warning) 32%, var(--border));
  background: color-mix(in oklab, var(--warning-soft) 34%, var(--bg-elevated));
}
.security-metric-card.danger {
  border-color: color-mix(in oklab, var(--danger) 30%, var(--border));
  background: color-mix(in oklab, var(--danger-soft) 30%, var(--bg-elevated));
}
.security-advice-list {
  display: grid;
  gap: 8px;
  margin-top: var(--s-3);
}
.security-advice-row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  align-items: start;
  gap: var(--s-3);
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}
.security-advice-row > span {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: var(--r-full);
  background: var(--accent);
}
.security-advice-row.warning > span { background: var(--warning); }
.security-advice-row.danger > span { background: var(--danger); }
.security-advice-row.success > span { background: var(--success); }
.security-advice-row strong {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.security-advice-row em {
  display: block;
  margin-top: 2px;
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-style: normal;
  line-height: var(--leading-snug);
}
.storage-warning,
.storage-empty {
  margin-top: var(--s-3);
  padding: var(--s-3);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  font-size: var(--text-sm);
}
.storage-warning {
  border: 1px solid color-mix(in oklab, var(--warning) 36%, var(--border));
  color: var(--warning);
}
.storage-path-list,
.storage-backup-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.storage-path-row,
.storage-backup-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: center;
  gap: var(--s-3);
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}
.storage-path-row span,
.storage-backup-row span,
.storage-backup-row em {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
}
.storage-path-row code {
  min-width: 0;
  color: var(--fg-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: normal;
  word-break: break-word;
}
.storage-backup-row {
  grid-template-columns: minmax(0, 1fr) auto;
}
.storage-backup-row strong {
  display: block;
  min-width: 0;
  color: var(--fg);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: normal;
  word-break: break-word;
}
.storage-backup-row em {
  font-style: normal;
  white-space: nowrap;
}
.settings-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
}
.settings-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.settings-form-grid .wide { grid-column: 1 / -1; }
.settings-form-grid textarea.input-wrap {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  border: 1px solid var(--border);
}
.settings-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--s-4);
}
.settings-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-2);
}
.settings-section-head .settings-section-desc { margin-bottom: 0; }
.settings-theme-control { width: max-content; }
.settings-swatch-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.settings-swatch {
  width: 34px;
  height: 34px;
  border-radius: var(--r-full);
  background: var(--c);
  border: 3px solid var(--bg-elevated);
  box-shadow: 0 0 0 1px var(--border);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.settings-swatch:hover { transform: translateY(-1px); box-shadow: 0 0 0 2px var(--border-strong); }
.settings-swatch:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--bg-elevated), 0 0 0 5px var(--accent); }
.settings-swatch.active { box-shadow: 0 0 0 2px var(--accent); }
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 3px 8px;
  border-radius: var(--r-full);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.status-pill.success {
  background: color-mix(in oklab, var(--success) 14%, white);
  color: var(--success);
}
.member-settings-row { padding: 10px 0; }
.settings-member-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.member-settings-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.member-settings-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  margin-left: auto;
}
.member-settings-main strong {
  display: block;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}
.member-settings-main span {
  display: block;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
}
.member-invite-form {
  display: grid;
  grid-template-columns: 1fr 1.25fr 1fr 0.9fr 0.9fr auto;
  gap: var(--s-2);
  align-items: center;
}
.member-invite-form .input-wrap {
  width: 100%;
  min-width: 0;
}
.settings-permission-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-3);
}
.settings-permission-card {
  padding: var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-raised);
}
.settings-permission-card strong {
  display: block;
  font-size: var(--text-lg);
  margin-bottom: 4px;
}
.settings-permission-card p {
  margin-bottom: var(--s-3);
  color: var(--fg-secondary);
  font-size: var(--text-sm);
}
.settings-permission-card span {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
}
.settings-permission-card .lucide {
  width: 13px;
  height: 13px;
  color: var(--success);
}
.settings-access-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: var(--s-3);
  align-items: start;
}
.settings-role-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.settings-role-card {
  min-width: 0;
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  color: var(--fg);
  text-align: left;
  cursor: pointer;
}
.settings-role-card:hover,
.settings-role-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.settings-role-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin-bottom: 4px;
}
.settings-role-card-head strong {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}
.settings-role-card-head em {
  font-style: normal;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
}
.settings-role-card p {
  margin: 0 0 8px;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}
.settings-role-perms {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.settings-role-perms span {
  max-width: 100%;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  font-size: 11px;
  font-weight: var(--weight-semibold);
}
.access-permission-section { margin: 0; }
.access-permission-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
}
.access-permission-group {
  min-width: 0;
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}
.access-permission-group > strong {
  display: block;
  margin-bottom: var(--s-2);
  font-size: var(--text-sm);
}
.access-permission-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
}
.access-permission-row input { accent-color: var(--accent); }
.access-member-list,
.access-audit-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.access-member-row { gap: var(--s-3); }
.access-role-select {
  width: 128px;
  flex: 0 0 128px;
}
.access-audit-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 128px;
  gap: var(--s-2);
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.access-audit-row:last-child { border-bottom: 0; }
.access-audit-row span,
.access-audit-row em {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-style: normal;
}
.access-audit-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.integration-card {
  position: relative;
  min-height: 150px;
}
.integration-settings-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.integration-status-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.integration-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in oklab, var(--c) 12%, white);
  color: var(--c) !important;
  font-weight: var(--weight-bold);
}
.integration-status-card .integration-mark {
  background: color-mix(in oklab, var(--integration-color) 14%, white);
  color: var(--integration-color) !important;
}
.integration-status-card .integration-mark::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: var(--r-sm);
  background: var(--integration-color);
}
.integration-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin-top: auto;
}
.integration-status-row em {
  margin: 0;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-style: normal;
}
.settings-card-actions {
  display: flex;
  gap: var(--s-2);
  margin-top: var(--s-1);
}
.settings-card-actions .btn {
  flex: 1;
}
.settings-device-list {
  display: flex;
  flex-direction: column;
}
.device-settings-row {
  gap: var(--s-2);
}
.device-settings-row .status-pill {
  margin-left: auto;
}
.billing-plan-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-3);
}
.billing-plan-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  min-width: 0;
  padding: var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  color: var(--fg-secondary);
  text-align: left;
  transition: all var(--t-fast) var(--ease-out);
}
.billing-plan-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}
.billing-plan-card:disabled,
.billing-plan-card.is-pending {
  cursor: wait;
  opacity: .68;
}
.billing-plan-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}
.billing-plan-card span {
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.billing-plan-card strong {
  color: var(--fg-primary);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
}
.billing-plan-card em {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-style: normal;
  line-height: var(--leading-snug);
}
.settings-agent-card {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-raised);
  margin-bottom: var(--s-2);
}
.settings-agent-card > div:nth-child(2) {
  flex: 1;
  min-width: 0;
}
.settings-agent-card strong { display: block; font-size: var(--text-md); }
.settings-agent-card p { color: var(--fg-secondary); font-size: var(--text-sm); }
.settings-usage-row {
  display: grid;
  grid-template-columns: minmax(0, 220px) 1fr;
  gap: var(--s-4);
  align-items: center;
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--border-subtle);
}
.settings-usage-row:last-child { border-bottom: 0; }
.settings-usage-row strong { display: block; font-size: var(--text-md); }
.settings-usage-row span { display: block; color: var(--fg-secondary); font-size: var(--text-sm); }
.usage-bar {
  height: 7px;
  overflow: hidden;
  border-radius: var(--r-full);
  background: var(--bg-subtle);
}
.usage-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}
.progress.small {
  height: 7px;
  background: var(--bg-subtle);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress.small > div {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

/* ============================================================
   Notifications Page
   ============================================================ */
.notif-shell { display: grid; grid-template-columns: 200px 1fr; gap: var(--s-6); }
.notif-nav { display: flex; flex-direction: column; gap: 2px; }
.notif-search {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  height: 36px;
  margin-bottom: var(--s-2);
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  transition: all var(--t-fast) var(--ease-out);
}
.notif-search svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.notif-search input {
  min-width: 0;
  width: 100%;
  color: var(--fg);
  font-size: var(--text-sm);
}
.notif-search input::placeholder { color: var(--fg-muted); }
.notif-search:focus-within {
  border-color: var(--accent);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-focus);
}
.notif-nav-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  font-size: var(--text-md);
  color: var(--fg-secondary);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-out);
  font-weight: var(--weight-medium);
}
.notif-nav-item:hover { background: var(--bg-subtle); color: var(--fg); }
.notif-nav-item.active { background: var(--accent-soft); color: var(--accent); }
.notif-nav-item .count { margin-left: auto; padding: 1px 6px; background: var(--bg-muted); color: var(--fg-secondary); border-radius: var(--r-full); font-size: var(--text-xs); font-weight: var(--weight-semibold); }
.notif-nav-item.active .count { background: var(--accent); color: white; }
.notif-list { display: flex; flex-direction: column; gap: var(--s-2); }
.notif-clear-confirm {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border: 1px solid color-mix(in oklab, var(--warning) 34%, var(--border));
  border-radius: var(--r-md);
  background: color-mix(in oklab, var(--warning-soft) 32%, var(--bg-elevated));
}
.notif-clear-confirm span {
  min-width: 0;
}
.notif-clear-confirm strong {
  display: block;
  color: var(--fg);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.notif-clear-confirm em {
  display: block;
  margin-top: 2px;
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-style: normal;
  line-height: var(--leading-snug);
}
.notif-clear-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.notif-clear-danger {
  border-color: var(--danger);
  background: var(--danger);
  color: white;
}
.notif-clear-danger:hover {
  border-color: color-mix(in oklab, var(--danger) 84%, black);
  background: color-mix(in oklab, var(--danger) 84%, black);
  color: white;
}
.notif-card {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: var(--s-3) var(--s-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  text-align: left;
  transition: all var(--t-fast) var(--ease-out);
  position: relative;
}
.notif-card.unread { border-left: 3px solid var(--accent); position: relative; }
.notif-card.unread::after { content: ''; position: absolute; top: 12px; left: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px oklch(from var(--accent) l c h / 0.15); }
/* P1-17: 未读状态保留左侧边线和小圆点，避免和右侧操作按钮冲突 */
.notif-card:hover { background: var(--bg-subtle); border-color: var(--border-strong); }
.notif-card.archived { opacity: 0.72; }
.notif-card.is-pending { cursor: wait; opacity: .82; }
.notif-icon {
  width: 32px; height: 32px;
  background: var(--bg-subtle);
  color: var(--c, var(--accent));
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.notif-body { flex: 1; min-width: 0; }
.notif-title { display: block; font-size: var(--text-md); font-weight: var(--weight-medium); margin-bottom: 2px; }
.notif-desc { display: block; font-size: var(--text-sm); color: var(--fg-secondary); line-height: var(--leading-snug); }
.notif-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.notif-chip { display: inline-flex; align-items: center; min-height: 18px; padding: 1px 6px; border-radius: var(--r-full); background: var(--bg-subtle); color: var(--fg-secondary); font-size: var(--text-xs); font-weight: var(--weight-semibold); }
.notif-time { display: block; font-size: var(--text-xs); color: var(--fg-tertiary); }
.notif-actions { display: flex; align-items: center; gap: 4px; opacity: .38; transform: translateY(0); transition: opacity var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out); }
.notif-card:hover .notif-actions,
.notif-card:focus-within .notif-actions,
.notif-card:focus-visible .notif-actions { opacity: 1; transform: translateY(0); }
.notif-action { min-width: 42px; height: 26px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--bg-elevated); color: var(--fg-secondary); font-size: var(--text-xs); font-weight: var(--weight-semibold); cursor: pointer; transition: all var(--t-fast) var(--ease-out); }
.notif-action:hover { border-color: var(--border-strong); color: var(--fg); background: var(--bg-subtle); }
.notif-action:disabled { cursor: wait; opacity: .64; }
.runtime-task,
.runtime-project,
.runtime-notification,
.runtime-task-card {
  animation: runtimeFadeIn 180ms var(--ease-out);
}

.runtime-project,
.runtime-project-link {
  width: 100%;
  border: 0;
  text-align: left;
  font: inherit;
}

.runtime-project .proj-row-head,
.runtime-project .proj-progress,
.runtime-project .proj-meta {
  display: flex;
}

.proj-progress {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: var(--r-full);
  overflow: hidden;
  margin-bottom: 6px;
}

.proj-progress > span {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--accent);
  transition: width 420ms var(--ease-out);
}

.proj-meta {
  gap: 4px;
  font-size: var(--text-xs);
  color: var(--fg-tertiary);
}

.kanban-empty {
  padding: 20px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  color: var(--fg-tertiary);
  font-size: var(--text-sm);
  text-align: center;
  background: var(--bg-elevated);
}

.task-detail-stack {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.task-detail-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.task-detail-title {
  font-size: 20px;
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}

.task-detail-desc {
  margin: 0;
  font-size: var(--text-md);
  color: var(--fg-secondary);
  line-height: var(--leading-relaxed);
}

.task-detail-panel,
.task-detail-section {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  padding: var(--s-4);
}

.task-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: 9px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
}

.task-detail-row:first-child { padding-top: 0; }
.task-detail-row:last-child { padding-bottom: 0; border-bottom: 0; }
.task-detail-row > span { color: var(--fg-secondary); }
.task-detail-row > strong { display: flex; align-items: center; gap: 8px; font-weight: var(--weight-semibold); }
.task-detail-row.editable { cursor: default; }
.task-detail-row.editable > span { flex: 0 0 auto; }
.task-field-control {
  width: min(220px, 58%);
  min-width: 0;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
  color: var(--fg);
  padding: 0 9px;
  font: inherit;
  font-size: var(--text-sm);
  transition: border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out), background-color var(--t-fast) var(--ease-out);
}
.task-field-control.compact { width: 92px; }
.task-field-control:hover { border-color: var(--border-strong); background: var(--bg); }
.task-field-control:focus-visible { outline: none; box-shadow: var(--shadow-focus); border-color: var(--accent); }

.task-progress-inline {
  min-width: 140px;
}

.task-progress-inline > span {
  width: 84px;
  height: 6px;
  border-radius: var(--r-full);
  background: var(--bg-elevated);
  overflow: hidden;
}

.task-progress-inline i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.task-detail-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}

.task-detail-section-head h4 {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

.task-detail-section-head span {
  font-size: var(--text-xs);
  color: var(--fg-tertiary);
}

.task-status-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.task-due-assist {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.task-due-assist p {
  margin: 0;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}
.task-due-assist.warning {
  border-color: color-mix(in oklab, var(--warning) 34%, var(--border));
  background: color-mix(in oklab, var(--warning) 8%, var(--bg-subtle));
}
.task-due-assist.danger {
  border-color: color-mix(in oklab, var(--danger) 34%, var(--border));
  background: color-mix(in oklab, var(--danger) 7%, var(--bg-subtle));
}
.task-due-assist.ok {
  border-color: color-mix(in oklab, var(--accent-emerald) 30%, var(--border));
}
.task-due-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.task-reminder-meta {
  color: var(--fg-tertiary) !important;
  font-size: var(--text-xs) !important;
}

.task-message-share {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.task-message-share > p {
  margin: 0;
  color: var(--fg-secondary);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}
.task-message-share-grid {
  display: grid;
  gap: var(--s-3);
}
.task-message-share-grid label {
  display: grid;
  gap: 6px;
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.task-message-share-grid select,
.task-message-share-grid textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
  color: var(--fg);
  font: inherit;
  font-size: var(--text-sm);
  transition: border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out), background-color var(--t-fast) var(--ease-out);
}
.task-message-share-grid select {
  height: 34px;
  padding: 0 10px;
}
.task-message-share-grid textarea {
  min-height: 72px;
  padding: 9px 10px;
  line-height: var(--leading-relaxed);
  resize: vertical;
}
.task-message-share-grid select:focus,
.task-message-share-grid textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.task-message-share-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}
.task-message-share-foot span,
.task-message-share-empty {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
}
.task-message-share-empty {
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
}

.task-attachment-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.task-attachment-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  color: var(--fg);
  text-align: left;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
}
.task-attachment-item:not(:disabled):hover {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
  box-shadow: var(--shadow-1);
}
.task-attachment-item:disabled {
  cursor: default;
  opacity: .72;
}
.task-attachment-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c, var(--accent));
  background: var(--bg-subtle);
  border-radius: var(--r-sm);
}
.task-attachment-icon .lucide {
  width: 20px;
  height: 20px;
}
.task-attachment-body {
  min-width: 0;
}
.task-attachment-body strong,
.task-attachment-body em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-attachment-body strong {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.task-attachment-body em,
.task-attachment-action {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-style: normal;
}
.task-attachment-action {
  font-weight: var(--weight-semibold);
}

.task-comments {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.task-comment {
  display: flex;
  gap: 10px;
}

.task-comment-head {
  font-size: var(--text-xs);
  color: var(--fg-tertiary);
  margin-bottom: 4px;
}

.task-comment-body {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 8px 10px;
}

.task-comment-empty {
  font-size: var(--text-sm);
  color: var(--fg-tertiary);
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--bg-elevated);
}

.task-comment-box {
  display: flex;
  gap: 8px;
  margin-top: var(--s-3);
}

.task-comment-box input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 10px;
  font-size: var(--text-sm);
  background: var(--bg-elevated);
}

.task-modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 var(--s-3);
}

.input-wrap select,
.input-wrap textarea,
.input-wrap input[type="datetime-local"] {
  flex: 1;
  min-width: 0;
  color: var(--fg);
  font: inherit;
}
@keyframes runtimeFadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Agent Conversation Page (full screen)
   ============================================================ */
.agent-conv-shell {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 0;
  background: color-mix(in oklch, var(--bg) 86%, var(--neutral-100));
}
.agent-conv-head {
  display: flex; align-items: center; gap: 12px;
  padding: 11px var(--s-5);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.agent-conv-head .ai-avatar { width: 34px; height: 34px; }
.agent-conv-head > div:nth-child(2) { min-width: 0; }
.agent-conv-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(640px, 1fr) 336px;
  background: color-mix(in oklch, var(--bg) 88%, var(--neutral-100));
}
.agent-conv-main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-subtle);
  background: color-mix(in oklch, var(--bg) 88%, var(--neutral-100));
}
.agent-conv-stream {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--s-5) clamp(var(--s-4), 5vw, var(--s-8)) var(--s-6);
}
.agent-conv-time {
  width: min(860px, 100%);
  margin: 0 auto var(--s-3);
  text-align: center;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  line-height: 1;
}
.agent-conv-message {
  width: min(860px, 100%);
  margin: 0 auto 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.agent-conv-message > div:last-child {
  min-width: 0;
  width: auto;
  max-width: min(680px, calc(100% - 42px));
}
.agent-conv-message.from-user {
  flex-direction: row-reverse;
}
.agent-conv-message.from-user > div:last-child {
  max-width: min(640px, calc(100% - 42px));
}
.agent-conv-msg-avatar {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--primary-500), var(--accent-purple));
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 13px;
  flex-shrink: 0;
}
.agent-conv-msg-bubble {
  position: relative;
  padding: 10px 13px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  border-top-left-radius: 4px;
  font-size: var(--text-md);
  line-height: var(--leading-relaxed);
  max-width: 100%;
  box-shadow: 0 1px 2px oklch(0 0 0 / 0.06);
  overflow-wrap: anywhere;
  word-break: normal;
}
.agent-conv-message .agent-run-card {
  width: 100%;
  max-width: 1120px;
}
.agent-conv-message.from-user .agent-conv-msg-bubble {
  background: var(--accent);
  color: var(--fg-on-accent);
  border-color: var(--accent);
  border-top-left-radius: 8px;
  border-top-right-radius: 4px;
  box-shadow: none;
}
.agent-conv-message.from-ai .agent-conv-msg-bubble {
  color: var(--fg);
}
.agent-conv-msg-bubble::before {
  content: "";
  position: absolute;
  top: 10px;
  width: 8px;
  height: 8px;
  background: inherit;
  border: inherit;
  transform: rotate(45deg);
}
.agent-conv-message.from-ai .agent-conv-msg-bubble::before {
  left: 2px;
  border-right: 0;
  border-top: 0;
}
.agent-conv-message.from-user .agent-conv-msg-bubble::before {
  right: 2px;
  border-left: 0;
  border-bottom: 0;
}
.agent-conv-msg-bubble.is-pending {
  color: var(--fg-secondary);
}
.agent-conv-msg-bubble br + br {
  display: block;
  content: "";
  margin-top: 8px;
}
.agent-reply-heading {
  display: inline-flex;
  margin: 10px 0 4px;
  color: var(--fg);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.agent-reply-bullet {
  width: 5px;
  height: 5px;
  display: inline-block;
  margin: 0 8px 2px 1px;
  border-radius: var(--r-full);
  background: var(--accent);
}
.agent-conv-input-bar {
  flex: 0 0 auto;
  padding: 12px clamp(var(--s-4), 5vw, var(--s-8));
  background: color-mix(in oklch, var(--bg-elevated) 86%, transparent);
  border-top: 1px solid var(--border);
}
.agent-conv-input-wrap {
  width: min(860px, 100%);
  margin: 0 auto;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 8px 8px var(--s-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all var(--t-fast) var(--ease-out);
  box-shadow: var(--shadow-1);
}
.agent-conv-input-wrap:focus-within { border-color: var(--accent); box-shadow: var(--shadow-focus); background: var(--bg-elevated); }
.agent-conv-input-wrap textarea { flex: 1; padding: 10px 0; font-size: var(--text-md); line-height: 1.55; resize: none; min-height: 52px; max-height: 184px; overflow-y: hidden; color: var(--fg); }
.agent-conv-context {
  min-width: 0;
  overflow-y: auto;
  padding: var(--s-4);
  background: var(--bg);
}
.agent-conv-context-section {
  display: grid;
  gap: var(--s-3);
  padding: 0 0 var(--s-4);
  margin-bottom: var(--s-4);
  border-bottom: 1px solid var(--border-subtle);
}
.agent-conv-context-section:last-child {
  border-bottom: 0;
  margin-bottom: 0;
  padding-bottom: 0;
}
.agent-conv-context-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}
.agent-conv-context-title span {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
}
.agent-conv-context-title strong {
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.agent-conv-context-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.agent-conv-context-grid div,
.agent-conv-skill,
.agent-conv-run-row {
  min-width: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
}
.agent-conv-context-grid div {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
}
.agent-conv-context-grid span,
.agent-conv-skill span,
.agent-conv-run-row em {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
}
.agent-conv-context-grid strong,
.agent-conv-skill strong,
.agent-conv-run-row strong {
  min-width: 0;
  color: var(--fg);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.agent-conv-skill-list,
.agent-conv-run-list,
.agent-conv-shortcuts {
  display: grid;
  gap: 8px;
}
.agent-conv-skill {
  display: grid;
  gap: 4px;
  padding: 10px;
}
.agent-conv-more {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-style: normal;
}
.agent-conv-shortcuts {
  grid-template-columns: 1fr;
}
.agent-conv-shortcuts .btn {
  justify-content: flex-start;
  width: 100%;
}
.agent-conv-run-row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  text-align: left;
}
.agent-conv-run-row span:last-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.agent-conv-run-row em {
  font-style: normal;
  line-height: var(--leading-snug);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.agent-conv-run-status {
  width: 8px;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--accent-emerald);
}
.agent-conv-run-status.failed { background: var(--danger); }

@media (max-width: 1180px) {
  .agent-conv-body { grid-template-columns: minmax(0, 1fr); }
  .agent-conv-main { border-right: 0; }
  .agent-conv-context { display: none; }
}

/* ============================================================
   Command Palette
   ============================================================ */
.command-palette {
  display: none;
  position: fixed; inset: 0; z-index: 1000;
  background: oklch(0.1 0.01 270 / 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  align-items: flex-start; justify-content: center;
  padding-top: 14vh;
}
.command-palette.open { display: flex; animation: fadeIn 150ms var(--ease-out); }
.command-box {
  width: 100%; max-width: 560px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-4);
  overflow: hidden;
  animation: slideDown 240ms var(--ease-out);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideDown { from { transform: translateY(-12px) scale(0.98); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
.command-input-row { position: relative; display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--fg-tertiary); }
.command-input-row input { flex: 1; font-size: var(--text-md); color: var(--fg); }
.command-input-row kbd { padding: 2px 6px; background: var(--bg-subtle); border-radius: var(--r-xs); font-size: 10px; color: var(--fg-tertiary); font-family: var(--font-mono); border: 1px solid var(--border); }
.command-submit { position: absolute; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none; overflow: hidden; }
.command-suggestions { max-height: 60vh; overflow-y: auto; padding: 8px; }
.command-section { margin-bottom: 8px; }
.command-section-title { padding: 6px 8px; font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--fg-tertiary); text-transform: uppercase; letter-spacing: 0.04em; }
.command-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-out);
  font-size: var(--text-md);
}
.command-item:hover,
.command-item.active { background: var(--accent-soft); color: var(--accent); }
.command-icon { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; font-size: 14px; position: relative; flex-shrink: 0; }
.command-item.is-unread .command-icon::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--bg-elevated);
}
.command-item-body { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 1px; }
.command-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.command-meta { color: var(--fg-tertiary); font-size: var(--text-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.command-item:hover .command-meta,
.command-item.active .command-meta { color: var(--accent); opacity: 0.82; }
.nexus-search-hit {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--fg-primary);
  border-radius: 4px;
  padding: 0 2px;
}
.command-empty { margin: var(--s-4); }
.command-item kbd { margin-left: auto; padding: 1px 5px; background: var(--bg-subtle); border-radius: var(--r-xs); font-size: 10px; color: var(--fg-tertiary); font-family: var(--font-mono); border: 1px solid var(--border); }
.command-item:hover kbd,
.command-item.active kbd { color: var(--accent); background: var(--bg-elevated); border-color: var(--accent-soft-strong); }

/* ============================================================
   Toast Notifications
   ============================================================ */
.toast-container { position: fixed; bottom: var(--s-6); right: var(--s-6); z-index: 2000; display: flex; flex-direction: column; gap: var(--s-2); pointer-events: none; }
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: var(--s-3) var(--s-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-4);
  min-width: 280px; max-width: 400px;
  pointer-events: auto;
  animation: toastIn 360ms var(--ease-out);
}
.toast.removing { animation: toastOut 240ms var(--ease-out) forwards; }
/* toastIn/Out 已在 1856-1862 定义（spring 版本） */
.toast-icon { width: 24px; height: 24px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; color: white; font-size: 12px; flex-shrink: 0; }
.toast-body { flex: 1; }
.toast-title { font-size: var(--text-sm); font-weight: var(--weight-semibold); margin-bottom: 2px; }
.toast-desc { font-size: var(--text-xs); color: var(--fg-secondary); }
.toast-action {
  align-self: center;
  border: 0;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  cursor: pointer;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  min-height: 28px;
  padding: 0 var(--s-3);
  white-space: nowrap;
}
.toast-action:hover {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}
.toast.success .toast-icon { background: var(--accent-emerald); }
.toast.info .toast-icon { background: var(--info); }
.toast.warning .toast-icon { background: var(--warning); }
.toast.danger .toast-icon { background: var(--danger); }

/* ============================================================
   Skeleton (loading)
   ============================================================ */
@keyframes shimmer { from { background-position: -200% 0; } to { background-position: 200% 0; } }
.skeleton {
  background: linear-gradient(90deg, var(--bg-subtle) 0%, var(--bg-muted) 50%, var(--bg-subtle) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
  border-radius: var(--r-sm);
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 1500;
  background: oklch(0.1 0.01 270 / 0.4);
  backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
  padding: var(--s-6);
}
.modal-overlay.open { display: flex; animation: fadeIn 150ms var(--ease-out); }
.modal {
  width: 100%; max-width: 480px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-5);
  animation: slideDown 240ms var(--ease-out);
  overflow: hidden;
}
.modal-head { padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border-subtle); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: var(--text-lg); font-weight: var(--weight-semibold); }
.modal-body { padding: var(--s-5); }
.modal-foot { padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border-subtle); display: flex; gap: var(--s-2); justify-content: flex-end; }

/* ============================================================
   Task Detail Drawer
   ============================================================ */
.drawer-overlay { display: none; position: fixed; inset: 0; z-index: 1200; background: oklch(0.1 0.01 270 / 0.3); backdrop-filter: blur(2px); }
.drawer-overlay.open { display: block; animation: fadeIn 150ms var(--ease-out); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 480px; max-width: 90vw;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-5);
  z-index: 1201;
  transform: translateX(100%);
  transition: transform 480ms var(--ease-emph); /* M4: 启用 ease-emph，drawer 更优雅 */
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border-subtle); }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--s-5); }

/* ============================================================
   Help Popover
   ============================================================ */
.help-popover {
  position: fixed;
  top: 64px;
  right: var(--s-5);
  z-index: 1450;
  width: min(360px, calc(100vw - var(--s-8)));
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-5);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-4px) scale(0.98);
  transition:
    opacity var(--t-fast) var(--ease-out),
    transform var(--t-fast) var(--ease-out),
    visibility var(--t-fast) var(--ease-out);
}
.help-popover.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.help-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-1) var(--s-1) var(--s-3);
}
.help-head h3 { font-size: var(--text-lg); font-weight: var(--weight-semibold); }
.help-kicker {
  margin-bottom: 2px;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.help-status {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
}
.help-status.connected { background: color-mix(in oklab, var(--success-soft) 45%, var(--bg-elevated)); }
.help-status strong { display: block; margin-bottom: 2px; font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.help-status p { color: var(--fg-secondary); font-size: var(--text-xs); line-height: var(--leading-snug); }
.help-storage-panel {
  display: grid;
  gap: var(--s-2);
  margin-top: var(--s-2);
  padding: var(--s-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
}
.help-storage-path {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-2);
}
.help-storage-path span {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.help-storage-path strong {
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: var(--weight-medium);
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.help-storage-path em {
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-style: normal;
}
.help-storage-path .help-storage-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.help-storage-path .help-storage-actions .btn {
  white-space: nowrap;
}
.help-data-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.help-data-grid span {
  display: grid;
  gap: 1px;
  min-width: 0;
  padding: 7px 6px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
  text-align: center;
}
.help-data-grid strong {
  color: var(--fg);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.help-data-grid em {
  color: var(--fg-tertiary);
  font-size: 10px;
  font-style: normal;
}
.help-backup-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-2);
  padding: 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  background: color-mix(in oklab, var(--bg-subtle) 68%, var(--bg-elevated));
}
.help-backup-row span {
  display: grid;
  gap: 1px;
  min-width: 0;
}
.help-backup-row strong {
  color: var(--fg);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.help-backup-row em {
  color: var(--fg-tertiary);
  font-size: 10px;
  font-style: normal;
  line-height: var(--leading-snug);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.help-backup-row .btn[disabled] {
  cursor: wait;
  opacity: 0.68;
}
.help-backup-list {
  display: grid;
  gap: 5px;
}
.help-backup-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-2);
  padding: 7px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm);
  background: var(--bg-subtle);
}
.help-backup-item.confirming {
  align-items: start;
  border-color: color-mix(in oklab, var(--warning) 36%, var(--border));
  background: color-mix(in oklab, var(--warning-soft) 24%, var(--bg-subtle));
}
.help-backup-item span {
  display: grid;
  gap: 1px;
  min-width: 0;
}
.help-backup-item strong {
  color: var(--fg-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: var(--weight-medium);
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.help-backup-item em {
  color: var(--fg-tertiary);
  font-size: 10px;
  font-style: normal;
}
.help-backup-item .btn[disabled] {
  cursor: wait;
  opacity: 0.68;
}
.help-restore-confirm {
  display: grid;
  grid-column: 1 / -1;
  gap: 7px;
  padding: 8px;
  border: 1px solid color-mix(in oklab, var(--warning) 30%, var(--border));
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
}
.help-restore-confirm strong {
  color: var(--fg);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.help-restore-confirm p {
  margin: 0;
  color: var(--fg-secondary);
  font-size: 10px;
  line-height: var(--leading-snug);
}
.help-restore-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}
.help-restore-danger {
  border-color: var(--danger);
  background: var(--danger);
  color: white;
}
.help-restore-danger:hover {
  border-color: color-mix(in oklab, var(--danger) 84%, black);
  background: color-mix(in oklab, var(--danger) 84%, black);
  color: white;
}
.help-action-grid {
  display: grid;
  gap: 6px;
  margin-top: var(--s-3);
}
.help-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  text-align: left;
  transition: background var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.help-action:hover,
.help-action:focus-visible {
  outline: none;
  border-color: var(--border);
  background: var(--bg-subtle);
}
.help-action strong { display: block; font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.help-action em {
  display: block;
  margin-top: 1px;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-style: normal;
  line-height: var(--leading-snug);
}
.help-action kbd,
.help-shortcut-row kbd {
  flex-shrink: 0;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  background: var(--bg-subtle);
  color: var(--fg-tertiary);
  font-family: var(--font-mono);
  font-size: 10px;
}
.help-shortcuts {
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--border-subtle);
}
.help-shortcuts-title {
  margin-bottom: var(--s-2);
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.help-shortcut-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 4px 0;
  color: var(--fg-secondary);
  font-size: var(--text-xs);
}

.workspace-popover {
  position: fixed;
  top: 64px;
  left: var(--s-5);
  z-index: 1460;
  width: min(380px, calc(100vw - var(--s-8)));
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-5);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-4px) scale(0.98);
  transition:
    opacity var(--t-fast) var(--ease-out),
    transform var(--t-fast) var(--ease-out),
    visibility var(--t-fast) var(--ease-out);
}
.workspace-popover.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.workspace-head {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--s-3);
  padding: var(--s-1) var(--s-1) var(--s-3);
}
.workspace-logo-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--primary-500), var(--accent-purple));
  color: white;
  font-weight: var(--weight-bold);
  box-shadow: var(--shadow-2);
}
.workspace-kicker {
  margin-bottom: 2px;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.workspace-head h3 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}
.workspace-head p {
  margin-top: 2px;
  color: var(--fg-secondary);
  font-size: var(--text-xs);
}
.workspace-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: var(--s-3);
}
.workspace-stat {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  text-align: left;
  transition: border-color var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
}
.workspace-stat:hover,
.workspace-stat:focus-visible {
  border-color: var(--accent);
  outline: none;
  transform: translateY(-1px);
}
.workspace-stat:active { transform: translateY(0); }
.workspace-stat span {
  display: block;
  color: var(--fg-tertiary);
  font-size: 11px;
  white-space: nowrap;
}
.workspace-stat strong {
  display: block;
  margin-top: 2px;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}
.workspace-stat.success { background: color-mix(in oklab, var(--success-soft) 42%, var(--bg-elevated)); }
.workspace-stat.accent { background: var(--accent-soft); }
.workspace-stat.warning { background: color-mix(in oklab, var(--warning-soft) 42%, var(--bg-elevated)); }
.workspace-stat.danger { background: color-mix(in oklab, var(--danger-soft) 42%, var(--bg-elevated)); }
.workspace-section {
  padding-top: var(--s-3);
  border-top: 1px solid var(--border-subtle);
}
.workspace-section + .workspace-section { margin-top: var(--s-3); }
.workspace-section-title {
  margin-bottom: var(--s-2);
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.workspace-route-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.workspace-route,
.workspace-project-row,
.workspace-admin-row {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  text-align: left;
  transition: background var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.workspace-route {
  min-height: 66px;
  padding: 9px 10px;
}
.workspace-route:hover,
.workspace-route:focus-visible,
.workspace-project-row:hover,
.workspace-project-row:focus-visible,
.workspace-admin-row:hover,
.workspace-admin-row:focus-visible {
  outline: none;
  border-color: var(--border);
  background: var(--bg-subtle);
}
.workspace-route strong,
.workspace-project-row strong,
.workspace-admin-row strong {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.workspace-route span,
.workspace-project-row em,
.workspace-admin-row em {
  display: block;
  margin-top: 2px;
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
  font-style: normal;
  line-height: var(--leading-snug);
}
.workspace-project-list,
.workspace-admin-list {
  display: grid;
  gap: 4px;
}
.workspace-project-row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  align-items: center;
  gap: var(--s-2);
  padding: 8px 9px;
}
.workspace-project-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--accent);
}
.workspace-admin-row {
  padding: 8px 9px;
}
.workspace-empty {
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  color: var(--fg-tertiary);
  font-size: var(--text-xs);
}
.workspace-storage {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-top: var(--s-3);
  padding: 9px 10px;
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  font-size: var(--text-xs);
}
.workspace-storage.connected { color: var(--fg); }
.workspace-storage-body {
  display: grid;
  min-width: 0;
  gap: 2px;
}
.workspace-storage .workspace-refresh {
  flex: 0 0 auto;
  margin-left: auto;
  white-space: nowrap;
}
.workspace-storage strong,
.workspace-storage em {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.workspace-storage strong {
  font-size: var(--text-xs);
}
.workspace-storage em {
  color: var(--fg-tertiary);
  font-style: normal;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1280px) {
  :root { --side-w: 72px; --side-expanded-w: 220px; --ai-w: 280px; }
  .app-shell { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .ai-card { grid-column: span 12; }
  .stat-card { grid-column: span 6; }
  .todo-card, .project-card { grid-column: span 12; }
  .activity-card, .calendar-card { grid-column: span 6; }
  .msg-shell { grid-template-columns: 260px minmax(0, 1fr); }
  .msg-detail { display: none; }
}
@media (max-width: 980px) {
  .app-shell { grid-template-columns: var(--side-w) 1fr; }
  .msg-shell { grid-template-columns: 240px 1fr; }
  .msg-detail { display: none; }
}

/* ============================================================
   R0 Fix: CJK 字距归零（避免负字距让中文挤压）
   ============================================================ */
:lang(zh) .login-hero h1,
:lang(zh) .login-card h2,
:lang(zh) .page-title,
:lang(zh) .msg-side-head h3,
:lang(zh) .agent-section-head h3,
:lang(zh) .kb-search-hero h2,
:lang(zh) .settings-section h3,
:lang(zh) .notif-card .notif-title,
:lang(zh) .report-card h3,
:lang(zh) .agent-conv-msg-bubble,
:lang(zh) .agent-card-name,
:lang(zh) .ai-msg-bubble {
  letter-spacing: 0;
}

/* R6 Fix: btn-primary 焦点环用浅底色对比，避免在紫底上看不见 */
.btn-primary:focus-visible {
  box-shadow: 0 0 0 2px var(--bg-elevated), 0 0 0 5px var(--accent);
}
.btn-primary.neutral:focus-visible {
  box-shadow: 0 0 0 3px var(--primary-100);
}

/* R4 Fix: SSO 图标尺寸 */
.sso-icon { width: 16px; height: 16px; flex-shrink: 0; }

/* R9 Fix: role-tag.bot 暗色模式 */
[data-theme="dark"] .role-tag.bot {
  background: oklch(0.3 0.12 305 / 0.3);
  color: oklch(0.8 0.15 305);
}

/* R12 Fix: brand-tag 暗色对比度增强 */
[data-theme="dark"] .brand-tag {
  color: var(--fg);
}

/* ============================================================
   M6: Empty State 组件（用户测试时备用）
   ============================================================ */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: var(--s-12) var(--s-6);
  text-align: center;
  color: var(--fg-tertiary);
}
.empty-state.is-hidden { display: none; }
.empty-state-icon {
  width: 48px; height: 48px;
  background: var(--bg-subtle);
  border-radius: var(--r-xl);
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-secondary);
  margin-bottom: var(--s-3);
}
.empty-state-title { font-size: var(--text-md); font-weight: var(--weight-semibold); margin-bottom: 4px; color: var(--fg); }
.empty-state-desc { font-size: var(--text-sm); color: var(--fg-secondary); margin-bottom: var(--s-4); max-width: 320px; line-height: var(--leading-relaxed); }

/* ============================================================
   Emoji → SVG 替换后的尺寸统一规则
   ============================================================ */
.lucide { width: 1em; height: 1em; flex-shrink: 0; vertical-align: -0.125em; }

/* msg-tag 中的 lucide */
.msg-tag .lucide { width: 12px; height: 12px; display: inline-block; vertical-align: -2px; }

/* ai-tag 中的 lucide */
.ai-tag .lucide { width: 11px; height: 11px; display: inline-block; vertical-align: -1px; }

/* msg-bubble 行内 emoji 装饰 */
.msg-bubble .lucide { width: 14px; height: 14px; display: inline-block; vertical-align: -2px; }

/* file-icon / space-icon / kb-card-icon / notif-icon / resource-icon / agent-cap / ai-chip 的 SVG */
.file-icon .lucide,
.space-icon .lucide,
.kb-card-icon .lucide,
.notif-icon .lucide,
.resource-icon .lucide,
.attach-icon .lucide,
.command-icon .lucide,
.agent-avatar .lucide {
  width: 24px; height: 24px;
  display: block;
}

/* ai-chip 行内 lucide */
.ai-chip .lucide { width: 14px; height: 14px; vertical-align: -2px; }

/* agent-cap 内的 lucide 偏小 */
.cap .lucide { width: 12px; height: 12px; vertical-align: -2px; }

/* task-meta-item 的 lucide 偏小 */
.task-meta-item .lucide { width: 11px; height: 11px; display: inline-block; vertical-align: -1px; }

/* settings-nav-item 内的 lucide */
.settings-nav-item .lucide { width: 14px; height: 14px; display: inline-block; vertical-align: -2px; }

/* msg-conv-name 里的 robot lucide */
.member-item .agent-avatar .lucide { width: 12px; height: 12px; display: block; }

/* Kanban 拖拽 placeholder */
.drag-placeholder {
  height: 56px;
  margin: 4px 0;
  border: 2px dashed var(--accent);
  border-radius: var(--r-md);
  background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  animation: placeholderPulse 1.2s ease-in-out infinite;
}
.drag-placeholder-inner {
  font-size: var(--text-sm);
  color: var(--accent);
  font-weight: var(--weight-medium);
}
@keyframes placeholderPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* ============================================================
   Round 4 Polish: 移动断点 + 全局 focus-visible + 微动效 + Empty state 用例
   ============================================================ */

/* 全局 focus-visible 默认（让 nav/card 类键盘可达） */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible,
.msg-conv:focus-visible,
.proj-row:focus-visible,
.activity:focus-visible,
.stat-card:focus-visible,
.cal-item:focus-visible,
.kb-card:focus-visible,
.kb-chip:focus-visible,
.ai-chip:focus-visible,
.ai-task:focus-visible,
.seg:focus-visible,
.notif-card:focus-visible,
.settings-nav-item:focus-visible,
.notif-nav-item:focus-visible,
.report-card:focus-visible,
.agent-card:focus-visible,
.space-card:focus-visible,
.file-card:focus-visible,
.proj-tab:focus-visible,
.kanban-tab:focus-visible,
.task-card:focus-visible,
.empty-state:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--accent-soft);
}
/* button 自带的 focus ring */
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 5px var(--accent); }
.btn-primary:focus-visible { box-shadow: 0 0 0 2px var(--bg-elevated), 0 0 0 5px var(--accent); }
.btn-primary.neutral:focus-visible { box-shadow: 0 0 0 3px var(--primary-100); }

/* Theme toggle 用 inline SVG 替代 ::after */
.theme-toggle .theme-icon-light,
.theme-toggle .theme-icon-dark {
  position: absolute; top: 50%; left: 4px; transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--warning);
  transition: all var(--t-mid) var(--ease-out);
  opacity: 1;
}
.theme-toggle .theme-icon-dark { color: var(--accent-purple); opacity: 0; transform: translate(16px, -50%); }
[data-theme="dark"] .theme-toggle .theme-icon-light { opacity: 0; transform: translate(-16px, -50%); }
[data-theme="dark"] .theme-toggle .theme-icon-dark { opacity: 1; transform: translateY(-50%) translateX(12px); }

/* Login footer lock SVG */
.login-footer-lock { display: inline-flex; align-items: center; margin-right: 6px; vertical-align: -2px; }
.login-footer-lock .lucide { width: 12px; height: 12px; }

/* Task card dragging 加 rotate + scale 让拖拽更"实" */
.task-card.dragging {
  opacity: 0.5;
  cursor: grabbing;
  transform: rotate(1.5deg) scale(1.02);
  box-shadow: var(--shadow-5);
}

/* Toast entrance */
.toast { animation: toastIn 220ms var(--ease-out); }
@keyframes toastIn {
  from { transform: translateX(120%) scale(0.9); opacity: 0; }
  to { transform: translateX(0) scale(1); opacity: 1; }
}
@keyframes toastOut {
  to { transform: translateX(120%) scale(0.9); opacity: 0; }
}

/* AI glow 更明显的呼吸 */
.ai-glow { animation: glowPulse 6s var(--ease-in-out) infinite; }
@keyframes glowPulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.15); opacity: 0.85; }
}

/* Empty state 内的 lucide icon */
.empty-state-icon .lucide { width: 24px; height: 24px; color: var(--fg-secondary); }

/* ============================================================
   Round 4 移动断点：768 / 640
   ============================================================ */
/* R7 Fix: 删除空的 980 块（合并到 1660 那条） */

@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 240px;
    max-width: min(82vw, 240px);
    transform: translateX(-100%);
    transition: transform 240ms var(--ease-out);
    z-index: 100;
    box-shadow: var(--shadow-5);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 90;
    background: oklch(0.12 0.01 270 / 0);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms var(--ease-out), background-color 180ms var(--ease-out);
  }
  .sidebar.open + .sidebar-backdrop {
    background: oklch(0.12 0.01 270 / 0.22);
    opacity: 1;
    pointer-events: auto;
  }
  .ai-panel,
  .ai-fab { display: none; }
  .breadcrumb { display: none; }
  .mobile-page-title { display: inline-block; max-width: 72px; }
  .topbar { gap: var(--s-2); padding: 0 var(--s-3); }
  .topbar-left { gap: var(--s-1); }
  .topbar-center { max-width: none; flex: 1 1 auto; min-width: 0; }
  .topbar-right { gap: var(--s-1); }
  .topbar-right .icon-btn[title="新建"],
  .topbar-right .icon-btn[title="帮助"],
  .topbar-right .topbar-divider,
  .topbar-right .avatar { display: none; }
  .search-box { padding: 7px 9px; }
  .search-box input { font-size: var(--text-sm); min-width: 0; }
  .search-box kbd { display: none; }
  .msg-shell { grid-template-columns: 1fr; }
  .msg-sidebar { display: none; }
  .msg-detail { display: none; }
  .msg-shell,
  .msg-main { height: calc(100dvh - var(--topbar-h)); }
  .msg-main-head { padding: var(--s-3) var(--s-4); }
  .msg-stream { padding: var(--s-4); }
  .msg-composer { padding: var(--s-2) var(--s-3) calc(var(--s-3) + env(safe-area-inset-bottom)); }
  .dashboard-grid { grid-template-columns: 1fr; gap: var(--s-3); }
  .stat-card, .ai-card, .todo-card, .project-card, .activity-card, .calendar-card { grid-column: span 1; }
  .ai-card { padding: var(--s-4); }
  .ai-head { align-items: flex-start; }
  .ai-suggestions { gap: 6px; }
  .ai-chip { max-width: 100%; }
  .dashboard-focus-list { grid-template-columns: 1fr; }
  .dashboard-focus-head { align-items: flex-start; }
  .ai-input { align-items: flex-end; }
  .ai-input input { min-width: 0; }
  .stat-card {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    grid-template-areas:
      "icon label"
      "icon value"
      "bar bar";
    column-gap: var(--s-3);
    row-gap: 4px;
    padding: var(--s-4);
  }
  .stat-icon { grid-area: icon; margin-bottom: 0; }
  .stat-label { grid-area: label; margin-bottom: 0; }
  .stat-value { grid-area: value; min-width: 0; flex-wrap: wrap; }
  .stat-bar { grid-area: bar; margin-top: var(--s-2); }
  .proj-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: var(--s-1);
    scroll-snap-type: x proximity;
  }
  .proj-tab {
    flex: 0 0 auto;
    min-width: max-content;
    scroll-snap-align: start;
  }
  .kanban {
    flex-direction: column;
    overflow: visible;
    margin: 0;
    padding: 0;
    scroll-snap-type: none;
  }
  .kanban-col {
    flex: 1 1 auto;
    width: 100%;
    min-height: auto;
    padding: var(--s-2);
    scroll-snap-align: none;
  }
  .kanban-col.add-col { display: none; }
  .kanban-head { min-height: 36px; }
  .kanban-empty { min-height: 64px; }
  .settings-shell { grid-template-columns: 1fr; }
  .settings-nav {
    flex-direction: row; overflow-x: auto; padding: 0 0 var(--s-2) 0;
    position: sticky; top: 0; z-index: 10;
    background: var(--bg-elevated);
  }
  .settings-nav-item { white-space: nowrap; }
  .settings-nav-section { display: none; }
  .notif-shell { grid-template-columns: 1fr; }
  .notif-nav { flex-direction: row; overflow-x: auto; }
  .notif-nav-item { white-space: nowrap; }
  .agent-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .view-scroll { padding: var(--s-4); }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .page-head { flex-direction: column; align-items: stretch; gap: var(--s-3); }
  .head-actions { flex-wrap: wrap; }
}

@media (max-width: 640px) {
  :root { --side-w: 0px; }
  .agent-conv-stream,
  .agent-conv-input-bar { padding: var(--s-3); }
  .agent-conv-message { width: 100%; }
  .agent-conv-input-wrap { padding: 6px 6px 6px 12px; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .kb-grid { grid-template-columns: 1fr; }
  .report-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: var(--text-xl); }
  .page-title { font-size: var(--text-xl); }
  .login-hero h1 { font-size: 36px; }
  .login-container { padding: 0 var(--s-4); gap: var(--s-6); }
  .topbar { padding: 0 var(--s-3); }
  .topbar-left .icon-btn[title="返回"] { display: none; }
  .mobile-page-title { max-width: 128px; }
  .topbar-center { flex: 0 0 auto; margin-left: auto; }
  .search-box {
    width: 32px;
    height: 32px;
    padding: 0;
    justify-content: center;
  }
  .search-box input,
  .search-box kbd { display: none; }
  .theme-toggle { width: 32px; }
  .page-sub { font-size: var(--text-base); }
  .btn { min-height: 34px; }
  .command-palette { padding: var(--s-3); padding-top: 10vh; }
  .command-box { max-width: 100%; border-radius: var(--r-lg); }
  .toast-container {
    top: auto;
    right: var(--s-3);
    bottom: var(--s-3);
    left: auto;
    max-width: min(300px, calc(100vw - var(--s-6)));
  }
  .toast {
    width: auto;
    min-width: 0;
    max-width: 100%;
    padding: 10px 12px;
  }
  ::-webkit-scrollbar { width: 6px; height: 6px; }
}

body.desktop-refactor .sidebar .user-card button.icon-btn[data-local-sign-out] {
  display: inline-flex !important;
  opacity: 1 !important;
  visibility: visible !important;
  max-width: none !important;
  pointer-events: auto !important;
  flex-shrink: 0;
}

body.desktop-refactor .sidebar .user-card .local-sign-out {
  display: inline-flex !important;
  opacity: 1 !important;
  visibility: visible !important;
  max-width: none !important;
  pointer-events: auto !important;
  flex-shrink: 0;
}

/* Mobile sidebar toggle button (添加到 topbar-left) */
.sidebar-toggle {
  display: none;
}
@media (max-width: 768px) {
  .sidebar-toggle { display: inline-flex; }
}

/* ============================================================
   Desktop refactor foundation
   ============================================================ */
@media (min-width: 769px) {
  body.desktop-refactor .app-shell {
    grid-template-columns: var(--side-expanded-w) minmax(0, 1fr);
  }

  body.desktop-refactor .sidebar,
  body.desktop-refactor .sidebar:hover,
  body.desktop-refactor .sidebar:focus-within,
  body.desktop-refactor .sidebar.expanded,
  body.desktop-refactor .sidebar.force-collapsed,
  body.desktop-refactor .sidebar.force-collapsed:hover,
  body.desktop-refactor .sidebar.force-collapsed:focus-within {
    width: var(--side-expanded-w);
    min-width: var(--side-expanded-w);
    z-index: 20;
    box-shadow: none;
  }

  body.desktop-refactor .sidebar .brand-name,
  body.desktop-refactor .sidebar .sidebar-head .icon-btn,
  body.desktop-refactor .sidebar .sidebar-search span,
  body.desktop-refactor .sidebar .sidebar-search kbd,
  body.desktop-refactor .sidebar .nav-label,
  body.desktop-refactor .sidebar .nav-item > span:not(.nav-dot):not(.proj-dot):not(.nav-badge):not(.nav-badge-mini),
  body.desktop-refactor .sidebar .user-info,
  body.desktop-refactor .sidebar .user-card .icon-btn {
    opacity: 1;
    visibility: visible;
    max-width: none;
    pointer-events: auto;
  }

  body.desktop-refactor .sidebar .brand-name,
  body.desktop-refactor .sidebar .sidebar-search span,
  body.desktop-refactor .sidebar .nav-item > span:not(.nav-dot):not(.proj-dot):not(.nav-badge):not(.nav-badge-mini),
  body.desktop-refactor .sidebar.force-collapsed .brand-name,
  body.desktop-refactor .sidebar.force-collapsed .sidebar-search span,
  body.desktop-refactor .sidebar.force-collapsed .nav-item > span:not(.nav-dot):not(.proj-dot):not(.nav-badge):not(.nav-badge-mini) {
    white-space: nowrap;
  }

  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .brand-name,
  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .sidebar-head .icon-btn,
  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .sidebar-search span,
  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .sidebar-search kbd,
  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-label,
  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-item > span:not(.nav-dot):not(.proj-dot):not(.nav-badge):not(.nav-badge-mini),
  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .user-info,
  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .user-card .icon-btn,
  body.desktop-refactor .sidebar.force-collapsed .brand-name,
  body.desktop-refactor .sidebar.force-collapsed .sidebar-head .icon-btn,
  body.desktop-refactor .sidebar.force-collapsed .sidebar-search span,
  body.desktop-refactor .sidebar.force-collapsed .sidebar-search kbd,
  body.desktop-refactor .sidebar.force-collapsed .nav-label,
  body.desktop-refactor .sidebar.force-collapsed .nav-item > span:not(.nav-dot):not(.proj-dot):not(.nav-badge):not(.nav-badge-mini),
  body.desktop-refactor .sidebar.force-collapsed .user-info,
  body.desktop-refactor .sidebar.force-collapsed .user-card .icon-btn {
    opacity: 1;
    visibility: visible;
    max-width: none;
    pointer-events: auto;
  }

  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .sidebar-head,
  body.desktop-refactor .sidebar.force-collapsed .sidebar-head {
    justify-content: space-between;
    padding: var(--s-4) var(--s-4) var(--s-3);
  }

  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .sidebar-search,
  body.desktop-refactor .sidebar.force-collapsed .sidebar-search {
    width: calc(100% - var(--s-6));
    height: auto;
    margin: 0 var(--s-3) var(--s-2);
    padding: 7px 10px;
    justify-content: flex-start;
    gap: 8px;
  }

  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .sidebar-nav,
  body.desktop-refactor .sidebar.force-collapsed .sidebar-nav {
    padding: var(--s-2) var(--s-2);
  }

  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-label,
  body.desktop-refactor .sidebar.force-collapsed .nav-label {
    height: auto;
    padding: var(--s-2) var(--s-3) 6px;
    margin: 0;
    overflow: visible;
  }

  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-section,
  body.desktop-refactor .sidebar.force-collapsed .nav-section {
    margin-bottom: var(--s-4);
  }

  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-item,
  body.desktop-refactor .sidebar.force-collapsed .nav-item {
    width: auto;
    height: auto;
    min-height: 34px;
    padding: 7px 10px;
    justify-content: flex-start;
    gap: 10px;
  }

  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-item.sub,
  body.desktop-refactor .sidebar.force-collapsed .nav-item.sub {
    padding-left: 28px;
  }

  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-badge,
  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-badge-mini,
  body.desktop-refactor .sidebar.force-collapsed .nav-badge,
  body.desktop-refactor .sidebar.force-collapsed .nav-badge-mini {
    position: static;
    width: auto;
    height: auto;
    min-width: 0;
    margin-left: auto;
    padding: 1px 6px;
    color: inherit;
    overflow: visible;
    border: 0;
  }

  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-dot,
  body.desktop-refactor .sidebar.force-collapsed .nav-dot {
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
  }

  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .sidebar-foot,
  body.desktop-refactor .sidebar.force-collapsed .sidebar-foot {
    padding: var(--s-3);
  }

  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .user-card,
  body.desktop-refactor .sidebar.force-collapsed .user-card {
    justify-content: flex-start;
    padding: 8px;
  }

  body.desktop-refactor .sidebar .sidebar-head,
  body.desktop-refactor .sidebar.force-collapsed .sidebar-head {
    justify-content: space-between;
    padding: var(--s-4) var(--s-4) var(--s-3);
  }

  body.desktop-refactor .sidebar .sidebar-search,
  body.desktop-refactor .sidebar.force-collapsed .sidebar-search {
    width: calc(100% - var(--s-6));
    height: auto;
    margin: 0 var(--s-3) var(--s-2);
    padding: 7px 10px;
    justify-content: flex-start;
    gap: 8px;
  }

  body.desktop-refactor .sidebar .sidebar-nav,
  body.desktop-refactor .sidebar.force-collapsed .sidebar-nav {
    padding: var(--s-2) var(--s-2);
  }

  body.desktop-refactor .sidebar .nav-label,
  body.desktop-refactor .sidebar.force-collapsed .nav-label {
    height: auto;
    padding: var(--s-2) var(--s-3) 6px;
    margin: 0;
    overflow: visible;
  }

  body.desktop-refactor .sidebar .nav-section,
  body.desktop-refactor .sidebar.force-collapsed .nav-section {
    margin-bottom: var(--s-4);
  }

  body.desktop-refactor .sidebar .nav-item,
  body.desktop-refactor .sidebar.force-collapsed .nav-item {
    width: auto;
    height: auto;
    min-height: 34px;
    padding: 7px 10px;
    justify-content: flex-start;
    gap: 10px;
  }

  body.desktop-refactor .sidebar .nav-item.sub,
  body.desktop-refactor .sidebar.force-collapsed .nav-item.sub {
    padding-left: 28px;
  }

  body.desktop-refactor .sidebar .nav-item.active::before,
  body.desktop-refactor .sidebar.force-collapsed .nav-item.active::before {
    left: -8px;
  }

  body.desktop-refactor .sidebar .nav-badge,
  body.desktop-refactor .sidebar .nav-badge-mini,
  body.desktop-refactor .sidebar.force-collapsed .nav-badge,
  body.desktop-refactor .sidebar.force-collapsed .nav-badge-mini {
    position: static;
    width: auto;
    height: auto;
    min-width: 0;
    margin-left: auto;
    padding: 1px 6px;
    color: inherit;
    overflow: visible;
    border: 0;
  }

  body.desktop-refactor .sidebar .nav-badge {
    color: white;
  }

  body.desktop-refactor .sidebar .nav-dot,
  body.desktop-refactor .sidebar.force-collapsed .nav-dot {
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
  }

  body.desktop-refactor .sidebar .sidebar-foot,
  body.desktop-refactor .sidebar.force-collapsed .sidebar-foot {
    padding: var(--s-3);
  }

  body.desktop-refactor .sidebar .user-card,
  body.desktop-refactor .sidebar.force-collapsed .user-card {
    justify-content: flex-start;
    padding: 8px;
  }

  body.desktop-refactor .sidebar .user-card [data-local-sign-out] {
    opacity: 1 !important;
    visibility: visible !important;
    max-width: none !important;
    pointer-events: auto !important;
    flex-shrink: 0;
  }

  body.desktop-refactor .workspace-popover {
    left: calc(var(--side-expanded-w) + var(--s-4));
    width: min(420px, calc(100vw - var(--side-expanded-w) - var(--s-8)));
  }

  body.desktop-refactor .drawer {
    width: min(520px, calc(100vw - var(--side-expanded-w) - 32px));
  }

  body.desktop-refactor .drawer-overlay.open {
    background: oklch(0.1 0.01 270 / 0.22);
    backdrop-filter: blur(1px);
  }

  body.desktop-refactor .dashboard-grid {
    align-items: start;
    grid-auto-flow: row dense;
  }

  body.desktop-refactor .ai-card {
    padding: var(--s-4);
  }

  body.desktop-refactor .stat-card {
    align-self: start;
    min-height: 124px;
    padding: var(--s-4);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
  }

  body.desktop-refactor .stat-icon {
    width: 32px;
    height: 32px;
    margin-bottom: var(--s-2);
  }

  body.desktop-refactor .stat-label {
    margin-bottom: 2px;
  }

  body.desktop-refactor .stat-value {
    font-size: var(--text-xl);
    letter-spacing: 0;
  }

  body.desktop-refactor .stat-bar {
    margin-top: auto;
  }

  body.desktop-refactor .drive-shell {
    grid-template-columns: 220px minmax(0, 1fr) 280px;
    min-height: 640px;
  }

  body.desktop-refactor .drive-tree,
  body.desktop-refactor .drive-detail-panel {
    padding: var(--s-3);
  }

  body.desktop-refactor .drive-toolbar {
    min-height: 58px;
    padding: 10px 12px;
  }

  body.desktop-refactor .drive-toolbar-right {
    gap: 6px;
  }

  body.desktop-refactor .drive-search {
    width: min(260px, 24vw);
    min-width: 180px;
  }

  body.desktop-refactor .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(184px, 1fr));
    align-content: start;
    gap: var(--s-2);
    padding: var(--s-3);
  }

  body.desktop-refactor .file-card {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    grid-template-areas:
      "icon badges"
      "icon name"
      "icon meta"
      "icon owner";
    column-gap: 10px;
    row-gap: 2px;
    min-height: 104px;
    padding: 10px;
  }

  body.desktop-refactor .file-card:hover {
    transform: translateY(-1px);
  }

  body.desktop-refactor .file-icon {
    grid-area: icon;
    width: 44px;
    height: 44px;
    aspect-ratio: auto;
    margin: 0;
    align-self: start;
  }

  body.desktop-refactor .file-card:hover .file-icon {
    transform: none;
  }

  body.desktop-refactor .file-icon .lucide {
    width: 22px;
    height: 22px;
  }

  body.desktop-refactor .file-badges {
    grid-area: badges;
    min-height: 18px;
    margin: 0;
    overflow: hidden;
    flex-wrap: nowrap;
  }

  body.desktop-refactor .file-badge {
    height: 18px;
    padding-inline: 5px;
    font-size: 10px;
    white-space: nowrap;
  }

  body.desktop-refactor .file-card:hover .file-badges,
  body.desktop-refactor .file-card:focus-within .file-badges {
    opacity: 0;
  }

  body.desktop-refactor .file-name {
    grid-area: name;
    margin: 0;
    line-height: var(--leading-snug);
  }

  body.desktop-refactor .file-meta {
    grid-area: meta;
    margin: 0;
  }

  body.desktop-refactor .file-owner {
    grid-area: owner;
  }

  body.desktop-refactor .file-actions {
    top: 8px;
    right: 8px;
    max-width: calc(100% - 68px);
    overflow: hidden;
  }

  body.desktop-refactor .file-action {
    height: 22px;
    padding: 0 6px;
    font-size: 10px;
  }

  body.desktop-refactor .file-card.upload {
    display: flex;
    min-height: 104px;
  }

  body.desktop-refactor .upload-zone {
    min-height: 82px;
    aspect-ratio: auto;
    padding: var(--s-2);
  }

  body.desktop-refactor .drive-detail-actions {
    gap: 6px;
  }

  body.desktop-refactor .drive-detail-actions .btn {
    min-height: 28px;
    height: 28px;
    padding-inline: 8px;
  }

  body.desktop-refactor .drive-info-list {
    gap: 8px;
  }

  body.desktop-refactor .drive-detail-summary div,
  body.desktop-refactor .drive-reference-card,
  body.desktop-refactor .drive-message-share-panel {
    padding: 8px;
  }

  body.desktop-refactor .kanban {
    overflow-x: hidden;
  }

  body.desktop-refactor .kanban-col {
    flex: 1 1 0;
    min-width: 0;
  }

  body.desktop-refactor .kanban-col.add-col {
    display: none;
  }

  body.desktop-refactor .msg-shell,
  body.desktop-refactor .msg-sidebar,
  body.desktop-refactor .msg-main {
    min-width: 0;
    overflow: hidden;
  }

  body.desktop-refactor .msg-list,
  body.desktop-refactor .msg-stream {
    overflow-x: hidden;
  }

  body.desktop-refactor .msg-conv,
  body.desktop-refactor .msg-conv-body,
  body.desktop-refactor .msg-conv-head,
  body.desktop-refactor .msg-conv-last,
  body.desktop-refactor .msg-composer,
  body.desktop-refactor .composer-foot,
  body.desktop-refactor .composer-hint {
    min-width: 0;
  }

  body.desktop-refactor .composer-hint {
    flex-wrap: wrap;
    row-gap: 2px;
  }

  body.desktop-refactor .ai-fab {
    right: var(--s-5);
    bottom: var(--s-5);
  }

  body.desktop-refactor[data-active-view="messages"] .ai-fab {
    bottom: 96px;
  }
}

body.desktop-refactor .sidebar .user-card button.icon-btn[data-local-sign-out] {
  display: inline-flex !important;
  opacity: 1 !important;
  visibility: visible !important;
  max-width: none !important;
  pointer-events: auto !important;
  flex-shrink: 0;
}

/* EOF desktop fluid overrides. This must remain after the desktop refactor block. */
@media (min-width: 769px) {
  body.desktop-refactor .app-shell {
    grid-template-columns: var(--side-w) minmax(0, 1fr);
  }

  body.desktop-refactor .sidebar {
    width: var(--side-w);
    min-width: var(--side-w);
    z-index: 20;
    box-shadow: none;
  }

  body.desktop-refactor .sidebar:hover,
  body.desktop-refactor .sidebar:focus-within,
  body.desktop-refactor .sidebar.expanded {
    width: var(--side-expanded-w);
    min-width: var(--side-expanded-w);
    z-index: 60;
    box-shadow: var(--shadow-5);
  }

  body.desktop-refactor .sidebar.force-collapsed,
  body.desktop-refactor .sidebar.force-collapsed:hover,
  body.desktop-refactor .sidebar.force-collapsed:focus-within {
    width: var(--side-w);
    min-width: var(--side-w);
    z-index: 20;
    box-shadow: none;
  }

  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .brand-name,
  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .sidebar-head .icon-btn,
  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .sidebar-search span,
  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .sidebar-search kbd,
  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-label,
  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-item > span:not(.nav-dot):not(.proj-dot):not(.nav-badge):not(.nav-badge-mini),
  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .user-info,
  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .user-card .icon-btn,
  body.desktop-refactor .sidebar.force-collapsed .brand-name,
  body.desktop-refactor .sidebar.force-collapsed .sidebar-head .icon-btn,
  body.desktop-refactor .sidebar.force-collapsed .sidebar-search span,
  body.desktop-refactor .sidebar.force-collapsed .sidebar-search kbd,
  body.desktop-refactor .sidebar.force-collapsed .nav-label,
  body.desktop-refactor .sidebar.force-collapsed .nav-item > span:not(.nav-dot):not(.proj-dot):not(.nav-badge):not(.nav-badge-mini),
  body.desktop-refactor .sidebar.force-collapsed .user-info,
  body.desktop-refactor .sidebar.force-collapsed .user-card .icon-btn {
    opacity: 0 !important;
    visibility: hidden !important;
    max-width: 0 !important;
    pointer-events: none !important;
  }

  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .sidebar-head,
  body.desktop-refactor .sidebar.force-collapsed .sidebar-head {
    justify-content: center;
    padding-inline: 0;
  }

  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .sidebar-search,
  body.desktop-refactor .sidebar.force-collapsed .sidebar-search {
    width: 40px;
    height: 40px;
    margin: 0 auto var(--s-2);
    padding: 0;
    justify-content: center;
    gap: 0;
  }

  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-item,
  body.desktop-refactor .sidebar.force-collapsed .nav-item {
    width: 40px;
    height: 40px;
    min-height: 40px;
    margin-inline: auto;
    padding: 0;
    justify-content: center;
    gap: 0;
  }

  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-label,
  body.desktop-refactor .sidebar.force-collapsed .nav-label {
    height: 8px;
    padding: 0;
    margin: 6px 0;
    overflow: hidden;
  }

  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-badge,
  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .nav-badge-mini,
  body.desktop-refactor .sidebar.force-collapsed .nav-badge,
  body.desktop-refactor .sidebar.force-collapsed .nav-badge-mini {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    min-width: 8px;
    height: 8px;
    padding: 0;
    overflow: hidden;
    color: transparent;
    border: 2px solid var(--bg-elevated);
  }

  body.desktop-refactor .sidebar:not(.expanded):not(:hover):not(:focus-within) .user-card,
  body.desktop-refactor .sidebar.force-collapsed .user-card {
    justify-content: center;
    padding: 4px;
  }

  body.desktop-refactor .topbar-center {
    max-width: min(720px, 38vw);
  }

  body.desktop-refactor .view-scroll {
    padding-inline: clamp(24px, 2.2vw, 48px);
  }

  body.desktop-refactor .workspace-popover {
    left: calc(var(--side-w) + var(--s-4));
    width: min(420px, calc(100vw - var(--side-w) - var(--s-8)));
  }

  body.desktop-refactor .drawer {
    width: min(520px, calc(100vw - var(--side-w) - 32px));
  }

  body.desktop-refactor .msg-shell {
    grid-template-columns: clamp(280px, 17vw, 420px) minmax(0, 1fr);
  }

  body.desktop-refactor .msg-stream {
    padding-inline: clamp(28px, 4vw, 112px);
  }

  body.desktop-refactor .msg-row {
    max-width: min(860px, 68%);
  }

  body.desktop-refactor .drive-shell {
    grid-template-columns: clamp(220px, 12vw, 300px) minmax(0, 1fr) clamp(280px, 17vw, 420px);
    min-height: min(760px, calc(100dvh - 172px));
  }

  body.desktop-refactor .drive-search {
    width: clamp(220px, 18vw, 360px);
  }

  body.desktop-refactor .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(clamp(184px, 10vw, 240px), 1fr));
  }

  body.desktop-refactor .settings-shell,
  body.desktop-refactor .settings-shell[data-enhanced="true"] {
    grid-template-columns: clamp(220px, 14vw, 280px) minmax(0, 1fr);
    max-width: min(1680px, 100%);
  }

  body.desktop-refactor .settings-content {
    max-width: min(1400px, 100%);
  }

  body.desktop-refactor .calendar-workspace {
    grid-template-columns: minmax(0, 1fr) clamp(320px, 22vw, 440px);
  }
}

@media (min-width: 1800px) {
  body.desktop-refactor .dashboard-grid {
    grid-template-columns: repeat(16, minmax(0, 1fr));
  }

  body.desktop-refactor .ai-card {
    grid-column: span 10;
  }

  body.desktop-refactor .stat-card {
    grid-column: span 3;
  }

  body.desktop-refactor .todo-card,
  body.desktop-refactor .project-card {
    grid-column: span 8;
  }

  body.desktop-refactor .activity-card,
  body.desktop-refactor .calendar-card {
    grid-column: span 4;
  }

  body.desktop-refactor .report-grid {
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  }

  body.desktop-refactor .agent-grid,
  body.desktop-refactor .kb-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
}




/* ============================================================
   Dashboard Refactor v2.6
   段式布局：Hero / 焦点 / KPI / 工作 / 数据
   ============================================================ */

/* ---------- Hero 横幅 ---------- */
.dash-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-5);
  padding: var(--s-5) var(--s-6);
  margin-bottom: var(--s-5);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  background:
    linear-gradient(135deg, var(--bg-elevated) 0%, oklch(0.97 0.018 245 / 0.7) 60%, oklch(0.95 0.04 305 / 0.55) 100%);
  position: relative;
  overflow: hidden;
}
[data-theme="dark"] .dash-hero {
  background:
    linear-gradient(135deg, var(--bg-elevated) 0%, oklch(0.22 0.05 260 / 0.55) 60%, oklch(0.22 0.06 305 / 0.5) 100%);
}
.dash-hero::before {
  content: '';
  position: absolute;
  top: -120px;
  right: -120px;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, oklch(0.7 0.18 285 / 0.18), transparent 70%);
  filter: blur(40px);
  pointer-events: none;
}
.dash-hero::after {
  content: '';
  position: absolute;
  bottom: -160px;
  left: 35%;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, oklch(0.74 0.16 75 / 0.12), transparent 70%);
  filter: blur(56px);
  pointer-events: none;
}
.dash-hero-main {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  position: relative;
  min-width: 0;
}
.dash-hero-avatar {
  position: relative;
  flex-shrink: 0;
}
.dash-hero-avatar .avatar {
  width: 60px;
  height: 60px;
  font-size: var(--text-2xl);
  box-shadow: var(--shadow-3), 0 0 0 4px oklch(1 0 0 / 0.6);
}
[data-theme="dark"] .dash-hero-avatar .avatar {
  box-shadow: var(--shadow-3), 0 0 0 4px oklch(0.18 0.02 270 / 0.8);
}
.dash-hero-avatar .status-dot {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 14px;
  height: 14px;
  border: 2.5px solid var(--bg-elevated);
}
.dash-hero-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dash-hero-text .page-title {
  margin-bottom: 0;
}
.dash-hero-text .page-sub {
  margin-top: 0;
}
.dash-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-4);
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}
.dash-hero-meta li {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-size: var(--text-xs);
  color: var(--fg-tertiary);
}
.dash-meta-num {
  font-size: 16px;
  font-weight: var(--weight-bold);
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.dash-meta-label {
  font-weight: var(--weight-medium);
}

.dash-hero-actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  position: relative;
}
.dash-quick {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 60px;
  padding: 8px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--fg-secondary);
  font-size: 11px;
  font-weight: var(--weight-medium);
  position: relative;
  transition: all var(--t-fast) var(--ease-out);
  cursor: pointer;
}
.dash-quick:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}
.dash-quick:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}
.dash-quick svg.lucide {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}
.dash-quick kbd {
  margin-top: 1px;
  padding: 0 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  font-size: 9px;
  color: var(--fg-tertiary);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}
.dash-quick-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--danger);
  color: white;
  border-radius: var(--r-full);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  font-style: normal;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-elevated);
  box-shadow: 0 1px 4px oklch(0.62 0.21 25 / 0.32);
  font-variant-numeric: tabular-nums;
}
.dash-quick-badge-dot {
  min-width: 8px;
  width: 8px;
  height: 8px;
  padding: 0;
  font-size: 0;
}

/* ---------- Dash Row 段容器 ---------- */
.dash-row {
  display: grid;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
}
.dash-row-focus {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}
.dash-row-work {
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
}
.dash-row-bottom {
  grid-template-columns: minmax(0, 5fr) minmax(0, 4fr) minmax(0, 3fr);
}

/* ---------- 优先级卡片 ---------- */
.priority-card {
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.priority-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-4);
}
.priority-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 4px;
  padding: 2px 8px;
  background: oklch(0.97 0.018 245 / 0.6);
  border: 1px solid oklch(0.92 0.03 245);
  border-radius: var(--r-full);
  color: var(--accent);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
[data-theme="dark"] .priority-eyebrow {
  background: oklch(0.3 0.12 280 / 0.18);
  border-color: oklch(0.4 0.1 280 / 0.3);
}
.priority-eyebrow svg {
  flex-shrink: 0;
}
.priority-card h3 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
}
.priority-sub {
  margin: 4px 0 0;
  font-size: var(--text-xs);
  color: var(--fg-tertiary);
  max-width: 30ch;
}
.priority-ring {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}
.priority-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.priority-ring-bg {
  fill: none;
  stroke: var(--bg-subtle);
  stroke-width: 4;
}
.priority-ring-fg {
  fill: none;
  stroke: url(#priority-grad, var(--accent));
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: var(--p, 0) 100;
  transition: stroke-dasharray 0.8s var(--ease-out);
}
.priority-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.priority-ring-center strong {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.priority-ring-center span {
  margin-top: 2px;
  font-size: 9px;
  color: var(--fg-tertiary);
  letter-spacing: 0.04em;
}

.priority-list {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.priority-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.priority-items > li {
  display: flex;
}
.priority-items > li .dashboard-focus-item {
  width: 100%;
}
.priority-foot {
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px dashed var(--border);
}
.priority-foot-hint {
  font-size: var(--text-xs);
  color: var(--fg-tertiary);
  line-height: var(--leading-snug);
}

/* 调整 focus-item 让它在 priority-card 中更紧凑 */
.priority-card .dashboard-focus-item {
  padding: 10px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  align-items: flex-start;
  gap: 10px;
}
.priority-card .dashboard-focus-item:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-2);
  transform: translateY(-1px);
}
.priority-card .focus-kind {
  min-width: 36px;
  max-width: 56px;
  height: 20px;
  font-size: 10px;
}
.priority-card .focus-main b {
  font-size: var(--text-sm);
  white-space: nowrap;
}
.priority-card .focus-main span {
  font-size: 11px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  white-space: normal;
}
.priority-card .focus-go {
  align-self: center;
  font-size: var(--text-md);
}
.priority-card .dashboard-focus-empty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-subtle);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  color: var(--fg-secondary);
  font-size: var(--text-sm);
}
.priority-card .dashboard-focus-empty:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- 节奏卡片 ---------- */
.rhythm-card {
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(160deg, var(--bg-elevated) 0%, oklch(0.97 0.02 265 / 0.6) 100%);
}
[data-theme="dark"] .rhythm-card {
  background:
    linear-gradient(160deg, var(--bg-elevated) 0%, oklch(0.2 0.05 260 / 0.4) 100%);
}
.rhythm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-3);
}
.rhythm-head h3 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
}
.rhythm-head .link {
  font-size: var(--text-xs);
}
.rhythm-main {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  margin-bottom: var(--s-4);
}
.rhythm-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.rhythm-ring {
  position: relative;
  width: 116px;
  height: 116px;
  flex-shrink: 0;
}
.rhythm-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.rhythm-ring-bg {
  fill: none;
  stroke: var(--bg-subtle);
  stroke-width: 9;
}
.rhythm-ring-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: var(--p, 0) 100;
  transition: stroke-dasharray 1s var(--ease-out);
  filter: drop-shadow(0 0 6px oklch(0.62 0.18 245 / 0.25));
}
.rhythm-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.rhythm-center strong {
  font-size: 24px;
  font-weight: var(--weight-bold);
  color: var(--fg);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.rhythm-center span {
  margin-top: 2px;
  font-size: 11px;
  color: var(--fg-tertiary);
  letter-spacing: 0.02em;
}
.rhythm-trend {
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  background: oklch(0.95 0.04 155);
  color: var(--success-strong);
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  font-style: normal;
  line-height: 1.2;
  white-space: nowrap;
}
.rhythm-trend.up { background: oklch(0.95 0.04 155); color: var(--success-strong); }
.rhythm-trend.down { background: oklch(0.95 0.04 25); color: var(--danger-strong); }
.rhythm-trend-sub {
  color: var(--fg-tertiary);
  font-weight: var(--weight-medium);
  margin-left: 2px;
}
.rhythm-info {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: auto auto;
  gap: 8px;
  align-content: stretch;
}
.rhythm-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  transition: all var(--t-fast) var(--ease-out);
  min-width: 0;
}
.rhythm-stat:hover {
  background: var(--bg-elevated);
  border-color: var(--border);
}
.rhythm-stat-label {
  font-size: 10px;
  font-weight: var(--weight-medium);
  color: var(--fg-tertiary);
  letter-spacing: 0.02em;
}
.rhythm-stat-value {
  font-size: 16px;
  font-weight: var(--weight-bold);
  color: var(--fg);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  white-space: nowrap;
}
.rhythm-stat-hint {
  font-size: 10px;
  color: var(--fg-tertiary);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rhythm-info .rhythm-trend {
  grid-column: span 2;
  justify-self: end;
  margin-top: 0;
}

.rhythm-meta {
  list-style: none;
  margin: 0;
  padding: var(--s-3) 0 0;
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-2);
}
.rhythm-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out);
}
.rhythm-cell:hover {
  background: var(--bg-subtle);
}
.rhythm-cell-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--c);
  border-radius: var(--r-sm);
  flex-shrink: 0;
}
.rhythm-cell > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.rhythm-cell strong {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--fg);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.rhythm-cell span {
  font-size: 10px;
  color: var(--fg-tertiary);
  letter-spacing: 0.02em;
}

/* ---------- KPI 数据条 ---------- */
.dash-kpi {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-4);
  margin-bottom: var(--s-5);
}
.dash-kpi > .stat-card,
.dash-row-bottom > .stat-card,
.dash-row > .stat-card {
  grid-column: auto;
}
.stat-card {
  position: relative;
  display: flex;
  flex-direction: column;
}
.stat-go {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-tertiary);
  font-size: var(--text-sm);
  opacity: 0;
  transform: translateX(-4px);
  transition: all var(--t-fast) var(--ease-out);
  pointer-events: none;
}
.stat-card:hover .stat-go,
.stat-card:focus-visible .stat-go {
  opacity: 1;
  transform: translateX(0);
  color: var(--accent);
}

/* ---------- 待办卡片 ---------- */
.todo-card {
  display: flex;
  flex-direction: column;
}
.todo-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-4);
  flex-wrap: wrap;
}
.todo-head-info {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  flex: 1;
  min-width: 200px;
}
.todo-head-info > div:first-child {
  min-width: 0;
  flex: 1;
}
.todo-card h3 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
}
.todo-progress {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  max-width: 320px;
}
.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-subtle);
  border-radius: var(--r-full);
  overflow: hidden;
  position: relative;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-purple));
  border-radius: var(--r-full);
  width: calc(var(--p, 0) * 1%);
  transition: width 0.8s var(--ease-out);
}
.todo-progress-label {
  font-size: var(--text-xs);
  color: var(--fg-tertiary);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.todo-tabs {
  flex-shrink: 0;
}
.todo-list {
  flex: 1;
}
.todo-item .todo-action {
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease-out);
}
.todo-item:hover .todo-action,
.todo-item:focus-within .todo-action {
  opacity: 1;
}
.todo-item .meta-due.urgent {
  color: var(--danger-strong);
  font-weight: var(--weight-semibold);
}
.todo-item[data-todo-priority="p0"] {
  border-left: 2px solid var(--danger);
}
.todo-item[data-todo-priority="p1"] {
  border-left: 2px solid var(--warning);
}
.todo-item[data-todo-priority="p2"] {
  border-left: 2px solid var(--info);
}
.todo-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px dashed var(--border);
  gap: var(--s-3);
}
.todo-add {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: var(--bg-subtle);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  transition: all var(--t-fast) var(--ease-out);
}
.todo-add:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  border-style: solid;
  color: var(--accent);
}
.todo-foot-hint {
  font-size: 11px;
  color: var(--fg-tertiary);
}
.todo-foot-hint kbd {
  display: inline-block;
  padding: 0 4px;
  margin: 0 1px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  font-size: 9px;
  font-family: var(--font-mono);
}

/* 待办 Tab 切换：根据 data-todo-active 过滤显示 */
.todo-list[data-todo-active="today"] .todo-item[data-todo-priority="p2"] {
  display: none;
}
.todo-list[data-todo-active="week"] .todo-item {
  display: flex;
}
.todo-list[data-todo-active="all"] .todo-item {
  display: flex;
}

/* ---------- 项目卡片 ---------- */
.project-card .card-head {
  margin-bottom: var(--s-3);
}
.proj-row {
  position: relative;
}
.proj-row-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}
.proj-risk {
  flex-shrink: 0;
  padding: 1px 6px;
  background: oklch(0.95 0.04 155);
  color: var(--success-strong);
  border-radius: var(--r-sm);
  font-size: 10px;
  font-weight: var(--weight-semibold);
}
.proj-risk-warn {
  background: oklch(0.96 0.05 75);
  color: var(--warning-strong);
}
.proj-risk-soon {
  background: oklch(0.95 0.04 25);
  color: var(--danger-strong);
}
.proj-go {
  margin-left: auto;
  color: var(--fg-tertiary);
  font-size: var(--text-md);
  opacity: 0;
  transform: translateX(-4px);
  transition: all var(--t-fast) var(--ease-out);
}
.proj-row:hover .proj-go {
  opacity: 1;
  transform: translateX(0);
  color: var(--accent);
}
.proj-row-head {
  margin-bottom: 6px;
}
.proj-row-foot {
  align-items: center;
  gap: 6px;
}
.proj-task-count {
  color: var(--fg);
  font-weight: var(--weight-medium);
}
.proj-dot-sep {
  color: var(--fg-muted);
}

/* ---------- 日程卡片 ---------- */
.calendar-card .card-head {
  margin-bottom: var(--s-3);
}
.card-sub {
  display: block;
  font-size: var(--text-xs);
  color: var(--fg-tertiary);
  margin-top: 2px;
}
.cal-timeline {
  position: relative;
  margin: 0 0 var(--s-2);
  height: 0;
}
.cal-now {
  position: absolute;
  top: 0;
  left: 54px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 1;
  pointer-events: none;
}
.cal-now-line {
  flex: 1;
  height: 1.5px;
  background: linear-gradient(90deg, var(--danger), oklch(0.62 0.21 25 / 0));
  border-radius: var(--r-full);
  position: relative;
}
.cal-now-line::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  box-shadow: 0 0 0 3px oklch(0.62 0.21 25 / 0.18);
}
.cal-now-label {
  flex-shrink: 0;
  padding: 1px 6px;
  background: var(--danger);
  color: white;
  border-radius: var(--r-sm);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 4px oklch(0.62 0.21 25 / 0.32);
}

.cal-item {
  position: relative;
}
.cal-item.live {
  background: linear-gradient(90deg, oklch(0.62 0.21 25 / 0.06), transparent 80%);
  border: 1px solid oklch(0.62 0.21 25 / 0.18);
  border-radius: var(--r-md);
  padding: 10px 8px;
}
.cal-tag {
  display: inline-block;
  padding: 0 6px;
  background: var(--bg, oklch(0.95 0.04 245));
  background: var(--bg);
  color: var(--c, var(--info));
  border-radius: var(--r-sm);
  font-size: 10px;
  font-weight: var(--weight-semibold);
}
.cal-people {
  display: inline-flex;
  align-items: center;
}
.cal-people .avatar {
  margin-left: -4px;
  border: 2px solid var(--bg-elevated);
}
.cal-people .avatar:first-child {
  margin-left: 0;
}
.cal-people-more {
  margin-left: 4px;
  padding: 0 5px;
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  border-radius: var(--r-full);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  line-height: 16px;
}
.cal-dot-status {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--fg-muted);
}
.cal-dot-live {
  background: var(--danger);
  box-shadow: 0 0 0 3px oklch(0.62 0.21 25 / 0.2);
  animation: calLivePulse 2s ease-in-out infinite;
}
.cal-dot-done {
  background: var(--success);
}
@keyframes calLivePulse {
  0%, 100% { box-shadow: 0 0 0 3px oklch(0.62 0.21 25 / 0.2); }
  50% { box-shadow: 0 0 0 6px oklch(0.62 0.21 25 / 0); }
}
.cal-item.past .cal-dot-status {
  background: var(--success);
}

/* ---------- 活动卡片 ---------- */
.activity-list .activity em {
  display: inline-block;
  margin-right: 5px;
  padding: 1px 5px;
  background: var(--warning-soft);
  color: var(--warning-strong);
  border-radius: var(--r-sm);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  font-style: normal;
}
.activity.runtime-activity.is-actionable .activity-time em {
  background: oklch(0.95 0.04 25);
  color: var(--danger-strong);
}

/* ---------- AI 助手新元素 ---------- */
.ai-avatar {
  position: relative;
}
.ai-avatar-pulse {
  position: absolute;
  inset: 0;
  border-radius: var(--r-md);
  background: oklch(0.62 0.18 245 / 0.18);
  animation: aiAvatarPulse 2.4s ease-in-out infinite;
  z-index: -1;
}
@keyframes aiAvatarPulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 0; }
}
.ai-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--s-3);
}
.ai-settings {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--fg-secondary);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-out);
}
.ai-settings:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.ai-input {
  position: relative;
}
.ai-input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--fg-tertiary);
  pointer-events: none;
  z-index: 1;
}
.ai-input input {
  padding-left: 32px !important;
}
.ai-suggestions .ai-chip:nth-child(n+5) {
  display: none;
}
@media (max-width: 1480px) {
  .ai-suggestions .ai-chip:nth-child(n+4) {
    display: none;
  }
  .ai-card-compact .ai-suggestions .ai-chip:nth-child(n+4) {
    display: inline-flex;
  }
  .ai-card-compact .ai-suggestions .ai-chip:nth-child(n+5) {
    display: inline-flex;
  }
  .ai-card-compact .ai-suggestions .ai-chip:nth-child(n+6) {
    display: none;
  }
}

/* ---------- 移除原 dashboard-grid 依赖 ---------- */
.dashboard-grid { display: contents; }

/* ---------- 响应式 ---------- */
@media (max-width: 1280px) {
  .dash-hero {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s-4);
    padding: var(--s-4) var(--s-5);
  }
  .dash-hero-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }
  .dash-row-focus { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
  .dash-row-work { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
}

@media (max-width: 1080px) {
  .dash-row-focus,
  .dash-row-work,
  .dash-row-bottom {
    grid-template-columns: minmax(0, 1fr);
  }
  .priority-items {
    grid-template-columns: 1fr;
  }
  .rhythm-main {
    flex-direction: column;
    align-items: stretch;
  }
  .rhythm-ring {
    margin: 0 auto;
  }
}

@media (max-width: 768px) {
  .dash-hero {
    padding: var(--s-3) var(--s-4);
  }
  .dash-hero-main {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s-3);
  }
  .dash-hero-avatar .avatar {
    width: 48px;
    height: 48px;
    font-size: var(--text-lg);
  }
  .dash-hero-actions {
    width: 100%;
    justify-content: space-between;
  }
  .dash-quick {
    min-width: 0;
    flex: 1;
    padding: 6px 8px;
  }
  .dash-quick span {
    display: none;
  }
  .dash-hero-actions .btn {
    flex: 1;
  }
  .dash-kpi {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .todo-head {
    flex-direction: column;
  }
  .todo-head-info {
    flex-direction: column;
    align-items: stretch;
  }
  .todo-tabs {
    align-self: flex-start;
  }
  .dash-row {
    margin-bottom: var(--s-4);
  }
}

@media (max-width: 540px) {
  .dash-kpi {
    grid-template-columns: 1fr;
  }
  .rhythm-meta {
    grid-template-columns: 1fr;
  }
  .priority-items {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Dashboard v2.6 Tab 折叠样式
   ============================================================ */

/* ---------- 主工作区 Tab 容器 ---------- */
.dash-workspace {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.dash-workspace-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 6px 0;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  position: relative;
  overflow-x: auto;
  scrollbar-width: thin;
}
.dash-workspace-nav::-webkit-scrollbar { height: 3px; }
.dash-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 8px 14px;
  background: transparent;
  border: none;
  border-radius: var(--r-md) var(--r-md) 0 0;
  color: var(--fg-tertiary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  position: relative;
  transition: color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
  white-space: nowrap;
}
.dash-tab svg {
  opacity: 0.7;
  transition: opacity var(--t-fast) var(--ease-out);
}
.dash-tab:hover {
  color: var(--fg);
  background: var(--bg-subtle);
}
.dash-tab:hover svg {
  opacity: 1;
}
.dash-tab.active {
  color: var(--accent);
  background: transparent;
  font-weight: var(--weight-semibold);
}
.dash-tab.active svg {
  opacity: 1;
}
.dash-tab.active::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-purple));
  border-radius: var(--r-full);
}
.dash-tab:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent);
  border-radius: var(--r-md);
}
.dash-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  border-radius: var(--r-full);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  font-style: normal;
  font-variant-numeric: tabular-nums;
  transition: all var(--t-fast) var(--ease-out);
}
.dash-tab.active .dash-tab-count {
  background: var(--accent-soft);
  color: var(--accent);
}
.dash-tab-count-warn {
  background: var(--danger-soft);
  color: var(--danger-strong);
}
.dash-tab.active .dash-tab-count-warn {
  background: var(--danger);
  color: white;
}
.dash-workspace-tail {
  margin-left: auto;
  padding-right: var(--s-3);
  display: flex;
  align-items: center;
}
.dash-workspace-meta {
  font-size: var(--text-xs);
  color: var(--fg-tertiary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.dash-workspace-meta::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 3px oklch(0.62 0.16 155 / 0.18);
}

.dash-workspace-body {
  position: relative;
  flex: 1;
}
.dash-panel {
  padding: var(--s-5);
  display: none;
  animation: dashPanelIn var(--t-mid) var(--ease-out);
}
.dash-panel.active {
  display: block;
}
@keyframes dashPanelIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.dash-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
  padding-bottom: var(--s-3);
  border-bottom: 1px dashed var(--border-subtle);
}
.dash-panel-head h3 {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}
.dash-panel-head .card-sub {
  margin-top: 2px;
}

/* ---------- 团队 tab 的分栏 ---------- */
.team-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: var(--s-5);
  align-items: start;
}
.team-mentions,
.team-stream {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  min-width: 0;
}
.team-section-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--s-1);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--fg-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.team-section-head svg {
  color: var(--accent);
}
.team-section-head em {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  background: var(--danger-soft);
  color: var(--danger-strong);
  border-radius: var(--r-full);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  font-style: normal;
  font-variant-numeric: tabular-nums;
}

/* ---------- 团队 tab 的紧凑 activity ---------- */
.activity-list.compact {
  gap: 2px;
}
.activity-list .activity-text {
  margin-top: 4px;
  font-size: var(--text-sm);
  color: var(--fg-secondary);
  line-height: var(--leading-snug);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.activity-list .activity-time {
  margin-top: 4px;
}

/* ---------- 主工作区底部 KPI ---------- */
.dash-workspace-foot {
  border-top: 1px solid var(--border-subtle);
  background: linear-gradient(180deg, transparent, var(--bg-subtle) 60%);
  padding: var(--s-3) var(--s-4);
}
.dash-workspace-foot .dash-kpi {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-3);
  margin-bottom: 0;
}
.dash-workspace-foot .stat-card {
  padding: var(--s-3) var(--s-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-out);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 84px;
}
.dash-workspace-foot .stat-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}
.dash-workspace-foot .stat-card:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}
.dash-workspace-foot .stat-icon {
  width: 32px;
  height: 32px;
  margin-bottom: 2px;
  border-radius: var(--r-sm);
}
.dash-workspace-foot .stat-icon svg {
  width: 16px;
  height: 16px;
}
.dash-workspace-foot .stat-label {
  font-size: 11px;
  color: var(--fg-tertiary);
  font-weight: var(--weight-medium);
}
.dash-workspace-foot .stat-value {
  font-size: 22px;
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  line-height: 1.1;
  display: flex;
  align-items: baseline;
  gap: 5px;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.dash-workspace-foot .stat-trend {
  font-size: 10px;
  font-weight: var(--weight-semibold);
  padding: 2px 6px;
  border-radius: var(--r-full);
  letter-spacing: 0;
}
.dash-workspace-foot .stat-unit {
  font-size: 12px;
  font-weight: var(--weight-medium);
  color: var(--fg-secondary);
}
.dash-workspace-foot .stat-bar {
  margin-top: auto;
  height: 3px;
  background: var(--bg-subtle);
  border-radius: var(--r-full);
  overflow: hidden;
}
.dash-workspace-foot .stat-go {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 18px;
  height: 18px;
  font-size: 12px;
  opacity: 0;
  transform: translateX(-4px);
  transition: all var(--t-fast) var(--ease-out);
}
.dash-workspace-foot .stat-card:hover .stat-go,
.dash-workspace-foot .stat-card:focus-visible .stat-go {
  opacity: 1;
  transform: translateX(0);
  color: var(--accent);
}

/* ---------- 紧凑 AI 助手（横条命令面板） ---------- */
.ai-card-compact {
  padding: var(--s-3) var(--s-4);
}
.ai-card-compact .ai-glow {
  display: none;
}
.ai-card-compact .ai-head {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-2);
  padding-bottom: 0;
  border-bottom: none;
}
.ai-card-compact .ai-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}
.ai-card-compact .ai-avatar svg {
  width: 18px;
  height: 18px;
}
.ai-card-compact .ai-meta {
  flex-shrink: 0;
  min-width: 160px;
  margin-right: 0;
  padding-right: var(--s-3);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ai-card-compact .ai-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.ai-card-compact .ai-status {
  font-size: 11px;
}
.ai-card-compact .ai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex: 1;
  margin: 0;
  justify-content: flex-end;
}
.ai-card-compact .ai-chip {
  padding: 4px 9px;
  font-size: var(--text-xs);
}
.ai-card-compact .ai-chip:nth-child(n+7) {
  display: none;
}
.ai-card-compact .ai-input {
  margin-top: 0;
  padding-left: 38px;
}
.ai-card-compact .ai-input-icon {
  left: 14px;
}

/* ---------- 把 .priority-card / .rhythm-card 中的 KPI cell 移除（已整合到 footer） ---------- */
.rhythm-card .rhythm-meta {
  display: none;
}
.rhythm-card {
  padding-bottom: var(--s-4);
}

/* ---------- 移除旧 .dashboard-grid 容器干扰 ---------- */
.dashboard-grid { display: contents; }

/* ---------- 整体节奏 ---------- */
.dash-row {
  display: grid;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
}
.dash-row-focus {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}

/* ---------- 响应式 ---------- */
@media (max-width: 1280px) {
  .dash-hero {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s-4);
    padding: var(--s-4) var(--s-5);
  }
  .dash-hero-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }
  .dash-row-focus { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
}

@media (max-width: 1080px) {
  .dash-row-focus { grid-template-columns: minmax(0, 1fr); }
  .priority-items { grid-template-columns: 1fr; }
  .team-split { grid-template-columns: 1fr; }
  .rhythm-main {
    flex-direction: column;
    align-items: stretch;
  }
  .rhythm-ring {
    margin: 0 auto;
  }
  .ai-card-compact .ai-suggestions {
    display: none;
  }
  .ai-card-compact .ai-meta {
    border-right: none;
    padding-right: 0;
    margin-right: 0;
  }
}

@media (max-width: 768px) {
  .dash-hero {
    padding: var(--s-3) var(--s-4);
  }
  .dash-hero-main {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s-3);
  }
  .dash-hero-avatar .avatar {
    width: 48px;
    height: 48px;
    font-size: var(--text-lg);
  }
  .dash-hero-actions {
    width: 100%;
    justify-content: space-between;
  }
  .dash-quick {
    min-width: 0;
    flex: 1;
    padding: 6px 8px;
  }
  .dash-quick span {
    display: none;
  }
  .dash-hero-actions .btn {
    flex: 1;
  }
  .dash-row {
    margin-bottom: var(--s-4);
  }
  .dash-workspace-foot .dash-kpi {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dash-workspace-foot .stat-bar {
    display: none;
  }
  .ai-card-compact .ai-head {
    flex-wrap: wrap;
  }
  .ai-card-compact .ai-meta {
    border-right: none;
    padding-right: 0;
    margin-right: 0;
    min-width: 0;
  }
}

@media (max-width: 540px) {
  .dash-workspace-foot .dash-kpi {
    grid-template-columns: 1fr;
  }
  .priority-items {
    grid-template-columns: 1fr;
  }
}
