/* =========================================================
   J Patent V4 —— 深海蓝 · 科技风主题 (Deep Blue)
   深色蓝底 + 微流控芯片背景 + 毛玻璃 + 霓虹光效
   ========================================================= */

:root {
  /* —— 背景层 —— */
  --bg: #0a1628;
  --bg-grad-a: #0a1628;
  --bg-grad-b: #0f1f3a;
  --bg-grad-c: #0c1b30;

  /* —— 毛玻璃表面 —— */
  --surface: rgba(12, 27, 48, 0.72);
  --surface-2: rgba(18, 36, 60, 0.55);
  --surface-solid: #0f1f38;

  /* —— 描边 —— */
  --border: rgba(59, 130, 246, 0.16);
  --border-strong: rgba(59, 130, 246, 0.34);
  --border-soft: rgba(59, 130, 246, 0.10);

  /* —— 文本 —— */
  --text: #E1E9F5;
  --muted: #93A5C9;
  --muted-2: #6A7B9E;

  /* —— 主色：深海蓝 —— */
  --primary: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --primary-50: rgba(59, 130, 246, 0.14);
  --primary-100: rgba(59, 130, 246, 0.24);
  --primary-grad: linear-gradient(135deg, #3b82f6, #06b6d4);
  --accent-grad: linear-gradient(135deg, #6366f1, #22d3ee);
  --primary-cyan: #06b6d4;

  /* —— 状态色（适配暗底）—— */
  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.14);
  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.14);
  --danger: #fb7185;
  --danger-bg: rgba(251, 113, 133, 0.14);

  /* —— 阴影 / 辉光 —— */
  --shadow-sm: 0 2px 12px rgba(8, 5, 20, 0.45);
  --shadow-md: 0 8px 30px rgba(8, 5, 20, 0.55);
  --glow: 0 0 22px rgba(59, 130, 246, 0.28);
  --glow-soft: 0 0 14px rgba(59, 130, 246, 0.18);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

/* ===================== 浅色工作区（工作页面） ===================== */
.view.light-mode {
  --bg: #f0f4f8;
  --bg-grad-a: #f0f4f8;
  --bg-grad-b: #e8edf4;
  --bg-grad-c: #eef2f6;
  --surface: rgba(255,255,255,0.96);
  --surface-2: rgba(240,244,248,0.85);
  --surface-solid: #ffffff;
  --border: rgba(59,130,246,0.14);
  --border-strong: rgba(59,130,246,0.28);
  --border-soft: rgba(59,130,246,0.07);
  --text: #1e293b;
  --muted: #6b7f9e;
  --muted-2: #8a9bb5;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
}
.view.light-mode .trend-card,
.view.light-mode .map-card,
.view.light-mode .card { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.view.light-mode .stat { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.view.light-mode .stat .n { color: #1e40af; text-shadow: none; }
.view.light-mode .stat .l { color: var(--muted); }
.view.light-mode .stat .ic { color: var(--primary); }
.view.light-mode .btn.primary { box-shadow: 0 2px 8px rgba(59,130,246,0.25); }
.view.light-mode .btn.ghost { color: var(--muted); }
.view.light-mode .btn.ghost:hover { background: rgba(59,130,246,0.08); color: var(--primary); }
.view.light-mode input,
.view.light-mode select,
.view.light-mode textarea { background: #fff; color: #1e293b; border-color: #d1d9e6; }
.view.light-mode input:focus,
.view.light-mode select:focus,
.view.light-mode textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.12); }
.view.light-mode .mod-card { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.view.light-mode .mod-card .mod-title { color: var(--text); }
.view.light-mode .mod-card .mod-desc { color: var(--muted); }
.view.light-mode .mod-badge { background: rgba(59,130,246,0.1); color: #3b82f6; }
.view.light-mode .mod-badge.ok { background: rgba(52,211,153,0.12); color: #059669; }
.view.light-mode .mod-badge.off { background: rgba(251,113,133,0.12); color: #e11d48; }
.view.light-mode .section-title { color: var(--text); }
.view.light-mode .doc-item .t { color: var(--text); }
.view.light-mode .doc-item .m { color: var(--muted); }
.view.light-mode .status-line { color: var(--text); }
.view.light-mode .search-sidebar { background: transparent; }
.view.light-mode .fopt { color: var(--text); }
.view.light-mode .fopt .c { color: var(--muted); }
.view.light-mode .fopt.active { background: rgba(59,130,246,0.1); color: #3b82f6; }
.view.light-mode .pagination .btn { color: var(--text); border-color: #d1d9e6; }
.view.light-mode .pagination .btn.primary { color: #fff; border-color: transparent; }
.view.light-mode .tag { background: rgba(59,130,246,0.08); color: #3b82f6; }
.view.light-mode .badge.cn { background: rgba(59,130,246,0.12); color: #2563eb; }
.view.light-mode .badge.jp { background: rgba(6,182,212,0.12); color: #0891b2; }
.view.light-mode .badge.ai,
.view.light-mode .badge.aiOrigin { background: rgba(59,130,246,0.08); color: #3b82f6; }
.view.light-mode .pill-toggle button { color: var(--text); border-color: #d1d9e6; }
.view.light-mode .pill-toggle button.active { background: rgba(59,130,246,0.1); color: #3b82f6; border-color: var(--primary); }
.view.light-mode .tab { color: var(--muted); }
.view.light-mode .tab.active { color: #3b82f6; border-bottom-color: var(--primary); }
.view.light-mode .gen-status.st-running { background: rgba(59,130,246,0.1); color: #3b82f6; }
.view.light-mode .preview code { background: rgba(59,130,246,0.08); color: #3b82f6; }
.view.light-mode .ai-panel-title { color: var(--text); }
.view.light-mode .mat-idx { background: rgba(59,130,246,0.08); color: #3b82f6; }
.view.light-mode .kb-item .kb-ftag { background: rgba(59,130,246,0.08); color: #3b82f6; }
.view.light-mode .prior-art .pa-cap { color: var(--text); }
.view.light-mode .drawer { background: var(--surface); color: var(--text); }
.view.light-mode .doc-item .doc-idx { background: rgba(59,130,246,0.08); color: #3b82f6; }
.view.light-mode .search-sidebar .fopt.active { background: rgba(59,130,246,0.1); color: #3b82f6; }
.view.light-mode .progress-bar { box-shadow: none; }
.view.light-mode .geo-company span { color: var(--text); }
.view.light-mode .geo-company span.muted { color: var(--muted); }
.view.light-mode .geo-company b { color: #1e40af; }
.view.light-mode .geo-patent { color: var(--text); }
.main.light-mode { background: #f0f4f8; }
.content.light-mode { background: #f0f4f8; }
/* ===================== 浅色模式下所有硬编码颜色修正 ===================== */
.view.light-mode .patent-card .abs { color: #4a5568; }
.view.light-mode .gen-title { color: #1e293b; }
.view.light-mode .stat .n { color: #1e40af; text-shadow: none; }
.view.light-mode .badge.cn { background: rgba(59,130,246,0.12); color: #2563eb; }
.view.light-mode .badge.us { background: rgba(251,113,133,0.12); color: #e11d48; }
.view.light-mode .badge.ep { background: rgba(52,211,153,0.12); color: #059669; }
.view.light-mode .badge.jp { background: rgba(6,182,212,0.12); color: #0891b2; }
.view.light-mode .badge.wo { background: rgba(251,191,36,0.12); color: #d97706; }
.view.light-mode .badge.ai, .view.light-mode .badge.aiOrigin { color: #3b82f6; }
.view.light-mode .tag { color: #3b82f6; }
.view.light-mode .mod-badge { color: #3b82f6; }
.view.light-mode .tab.active { color: #3b82f6; }
.view.light-mode .pill-toggle button.active { color: #3b82f6; }
.view.light-mode .ai-panel-title { color: #1e293b; }
.view.light-mode .mat-idx { color: #3b82f6; }
.view.light-mode .prior-art .pa-cap { color: #1e293b; }
.view.light-mode .kb-item .kb-ftag { color: #3b82f6; }
.view.light-mode .doc-item .doc-idx { color: #3b82f6; }
.view.light-mode .search-sidebar .fopt.active { color: #3b82f6; }
.view.light-mode .gen-status.st-running { color: #3b82f6; }
.view.light-mode .gen-status.st-paused { color: #d97706; }
.view.light-mode .gen-status.st-done { color: #059669; }
.view.light-mode .gen-status.st-error { color: #e11d48; }
.view.light-mode .gen-status.st-cancelled { color: #6b7f9e; }
.view.light-mode .gen-err { color: #e11d48; }
.view.light-mode .gen-float { background: #fff; color: #1e293b; }
.view.light-mode .login-err { color: #e11d48; }
.view.light-mode .drawer { background: #fff; color: #1e293b; }
body {
  font-family: var(--font);
  background: var(--bg-grad-a);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }

/* ===================== 全站背景层 ===================== */
.app-bg {
  position: fixed; inset: 0; z-index: 0; overflow: hidden;
  background:
    radial-gradient(1200px 700px at 80% -10%, rgba(59,130,246,0.22), transparent 60%),
    radial-gradient(1000px 600px at -10% 110%, rgba(6,182,212,0.16), transparent 55%),
    linear-gradient(160deg, var(--bg-grad-a) 0%, var(--bg-grad-c) 50%, var(--bg-grad-b) 100%);
  pointer-events: none;
}
.app-bg-chip {
  position: absolute; inset: 0;
  background-image: url("../img/microfluidic-bg.svg");
  background-size: cover; background-position: center;
  opacity: 0.5;
  mix-blend-mode: screen;
}
.app-bg-glow {
  position: absolute; border-radius: 50%; filter: blur(40px); opacity: 0.5;
}
.app-bg-glow.glow-a {
  width: 420px; height: 420px; top: -120px; right: -80px;
  background: radial-gradient(circle, rgba(59,130,246,0.5), transparent 70%);
}
.app-bg-glow.glow-b {
  width: 480px; height: 480px; bottom: -160px; left: -120px;
  background: radial-gradient(circle, rgba(6,182,212,0.35), transparent 70%);
}
.app-bg-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(59,130,246,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59,130,246,0.05) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 40%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(circle at 50% 40%, #000 0%, transparent 78%);
}

/* ===================== Layout ===================== */
.layout { display: flex; min-height: 100vh; position: relative; z-index: 1; }

.sidebar {
  width: 240px; flex-shrink: 0;
  background: linear-gradient(180deg, rgba(30,23,58,0.78), rgba(22,16,44,0.7));
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  box-shadow: 4px 0 24px rgba(8,5,20,0.35);
}
.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 18px 18px 16px; border-bottom: 1px solid var(--border);
  position: relative;
}
.brand .logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--primary-grad);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 13px; letter-spacing:-.3px;
  box-shadow: 0 0 16px rgba(59,130,246,0.55);
}
.brand .name { font-weight: 700; font-size: 16px; letter-spacing: .3px; color: var(--text); }
.brand .sub { font-size: 11px; color: var(--muted); margin-top: 1px; letter-spacing: .5px; }

.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; margin: 3px 0; border-radius: var(--radius-sm);
  color: #e0e8f5; font-weight: 600; text-shadow: 0 1px 4px rgba(0,0,0,0.35); cursor: pointer; user-select: none;
  transition: background .18s, color .18s, box-shadow .18s, transform .12s;
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-soft); }
.nav-item.active {
  background: linear-gradient(135deg, var(--primary-100), rgba(6,182,212,0.12));
  color: #fff; font-weight: 600; border-color: var(--border-strong);
  box-shadow: var(--glow-soft);
}
.nav-item .ico { width: 18px; height: 18px; flex-shrink: 0; filter: drop-shadow(0 0 4px rgba(59,130,246,0.4)); }

/* 侧边栏分组 */
.nav-group { margin: 2px 0; }
.nav-group-title {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; margin: 3px 0; border-radius: var(--radius-sm);
  color: var(--text); font-weight: 600; cursor: pointer; user-select: none; font-size: 13px;
}
.nav-group-title:hover { background: var(--surface-2); }
.nav-group-title .ico { width: 18px; height: 18px; flex-shrink: 0; }
.nav-group-title .g-label { flex: 1; letter-spacing: .3px; }
.nav-group-title .caret {
  font-size: 10px; color: var(--muted); transition: transform .15s ease;
  transform: rotate(90deg);
}
.nav-group.collapsed .caret { transform: rotate(0deg); }
.nav-group.collapsed .nav-group-items { display: none; }
.nav-group.active > .nav-group-title { color: var(--primary); text-shadow: 0 0 10px rgba(59,130,246,0.4); }
.nav-item.sub { padding-left: 36px; position: relative; font-size: 13px; }
.nav-item.sub::before {
  content: ""; position: absolute; left: 23px; top: 0; bottom: 0;
  border-left: 1px solid var(--border-strong);
}
.nav-item.sub .ico { width: 16px; height: 16px; opacity: .9; }

.sidebar-foot {
  padding: 12px 14px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted-2);
  background: rgba(15,10,30,0.3);
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0;
}
.ver-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }

/* 折叠按钮 — 独立 flex 子项，在 nav 和 sidebar-foot 之间，固定高度不偏移 */
.sidebar-toggle {
  height: 32px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  cursor: pointer; color: #6b7280; transition: all .25s ease;
  font-size: 11px; white-space: nowrap;
  background: rgba(15,10,30,0.3);
}
.sidebar-toggle:hover { color: #a5b4fc; background: rgba(99,102,241,0.08); }
.sidebar-toggle:active { background: rgba(99,102,241,0.15); }
.sidebar-toggle svg { transition: transform .25s ease; }
.sidebar-toggle.is-collapsed svg { transform: rotate(180deg); }
.sidebar-toggle.is-collapsed .toggle-label { display: none; }
/* 折叠后 sidebar-foot 内容隐藏 */
.sidebar.collapsed .sidebar-foot > * { display: none; }
/* 只保留角色名和退出按钮，隐藏数据源和版本号 */
.sidebar-foot .src-badge,
.sidebar-foot .ver-text { display: none; }

/* 折叠侧边栏 */
.sidebar.collapsed { width: 56px; }
.sidebar.collapsed .brand > .logo + div { display: none; }
.sidebar.collapsed .nav-item span:not(.ico) { display: none; }
.sidebar.collapsed .nav-group-title .g-label { display: none; }
.sidebar.collapsed .nav-group-title .caret { display: none; }
.sidebar.collapsed .nav-group-items { display: none; }
.sidebar.collapsed .nav-item.sub { padding-left: 12px; }
.sidebar.collapsed .nav-item.sub::before { display: none; }
.sidebar.collapsed .src-badge span:last-child { display: none; }
.sidebar.collapsed .sidebar-foot .ver-text { display: none; }
.sidebar.collapsed #logoutBtn { display: none !important; }
.src-badge { display: inline-flex; align-items: center; gap: 6px; }
.src-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.src-dot.live { background: var(--success); box-shadow: 0 0 6px var(--success); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 62px; background: linear-gradient(180deg, rgba(28,21,54,0.85), rgba(24,18,46,0.6));
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 700; color: var(--text); letter-spacing: .3px; }
.topbar .crumb { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.content { padding: 26px; flex: 1; }
.view { max-width: 100%; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===================== Cards ===================== */
.card {
  background: var(--surface);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: border-color .2s, box-shadow .2s, transform .15s;
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.card-pad { padding: 18px 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { margin: 0; font-size: 15px; color: var(--text); }

/* ===================== Buttons ===================== */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text); padding: 8px 14px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; cursor: pointer; transition: all .18s; white-space: nowrap;
}
.btn:hover { background: rgba(59,130,246,0.16); border-color: var(--primary); box-shadow: var(--glow-soft); }
.btn.primary {
  background: var(--primary-grad); border-color: transparent; color: #fff;
  box-shadow: 0 4px 16px rgba(59,130,246,0.4);
}
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 6px 22px rgba(59,130,246,0.55); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.xs { padding: 2px 8px; font-size: 11.5px; border-radius: 6px; }
.btn.danger { color: var(--danger); border-color: rgba(251,113,133,0.4); background: var(--danger-bg); }
.btn.danger:hover { background: rgba(251,113,133,0.22); box-shadow: 0 0 14px rgba(251,113,133,0.25); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
/* AI 修订高亮按钮：渐变底 + 发光 + 脉冲，吸引注意 */
.btn.ai-revive {
  background: linear-gradient(135deg, #6366f1, #8b5cf6, #22d3ee);
  background-size: 200% 200%;
  color: #fff !important;
  border: 1px solid rgba(167,139,250,0.7);
  font-weight: 700;
  letter-spacing: .5px;
  box-shadow: 0 0 16px rgba(99,102,241,0.55), 0 2px 10px rgba(99,102,241,0.35);
  animation: revivePulse 2.4s ease-in-out infinite;
}
.btn.ai-revive:hover {
  background-position: 100% 50%;
  box-shadow: 0 0 26px rgba(139,92,246,0.85), 0 4px 18px rgba(99,102,241,0.5);
  transform: translateY(-1px) scale(1.04);
}
@keyframes revivePulse {
  0%, 100% { box-shadow: 0 0 10px rgba(99,102,241,0.35), 0 2px 10px rgba(99,102,241,0.25); }
  50%      { box-shadow: 0 0 24px rgba(139,92,246,0.8),  0 2px 14px rgba(99,102,241,0.45); }
}

/* ===================== Forms ===================== */
.field { margin-bottom: 14px; }
.field > label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--text); }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
input[type=text], input[type=search], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-size: 13.5px; font-family: inherit; color: var(--text);
  background: rgba(15,10,30,0.45); transition: border .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.22);
}
select option { background: #fff; color: #1e293b; }
textarea { resize: vertical; line-height: 1.6; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ===================== Badges / Tags ===================== */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge.cn { background: rgba(59,130,246,0.18); color: #93c5fd; }
.badge.us { background: rgba(251,113,133,0.16); color: #fda4af; }
.badge.ep { background: rgba(52,211,153,0.16); color: #6ee7b7; }
.badge.jp { background: rgba(6,182,212,0.16); color: #f9a8d4; }
.badge.wo { background: rgba(251,191,36,0.16); color: #fcd34d; }
.badge.ok { background: var(--success-bg); color: var(--success); }
.badge.warn { background: var(--warning-bg); color: var(--warning); }
.badge.gray { background: var(--surface-2); color: var(--muted); }
.badge.ai, .badge.aiOrigin { background: var(--primary-50); color: #93c5fd; }
.tag { display: inline-block; background: var(--primary-50); color: #93c5fd; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; margin: 2px 4px 2px 0; }

/* ===================== 数据源分段切换 ===================== */
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg-btn { border: 0; background: var(--surface-2); color: var(--muted); padding: 6px 14px; font-size: 13px; cursor: pointer; font-family: inherit; transition: all .15s; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.active { background: var(--primary-grad); color: #fff; font-weight: 600; }
.seg-btn:not(.active):hover { background: var(--primary-50); color: var(--text); }

/* ===================== Stats ===================== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
@media (max-width: 760px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat {
  position: relative; overflow: hidden;
  background: var(--surface); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm);
  transition: border-color .2s, box-shadow .2s, transform .15s;
}
.stat:hover { border-color: var(--border-strong); box-shadow: var(--glow-soft); transform: translateY(-2px); }
.stat::before {
  content: ""; position: absolute; left: 0; top: 0; width: 3px; height: 100%;
  background: var(--accent-grad); opacity: .8;
}
.stat .n { font-size: 26px; font-weight: 800; letter-spacing: -.5px; color: #f3e8ff; text-shadow: 0 0 14px rgba(192,132,252,0.45); }
.stat .l { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.stat .ic {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: var(--primary-50); color: #93c5fd; font-size: 15px; margin-bottom: 10px;
  box-shadow: inset 0 0 10px rgba(59,130,246,0.25);
}

/* ===================== Search ===================== */
.search-bar { display: flex; gap: 10px; }
.search-bar input { flex: 1; }
.filters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 12px; }
@media (max-width: 900px) { .filters { grid-template-columns: repeat(2, 1fr); } }
.adv-filters { margin-top: 14px; border-top: 1px dashed var(--border); padding-top: 12px; }
.adv-filters .af-title { margin-bottom: 2px; }
.result-list { margin-top: 18px; display: flex; flex-direction: column; gap: 12px; }
.patent-card {
  cursor: pointer; transition: box-shadow .15s, transform .08s, border-color .15s;
  background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
}
.patent-card:hover { box-shadow: var(--glow-soft); border-color: var(--border-strong); }
.patent-card .pc-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.patent-card h4 { margin: 0 0 6px; font-size: 15px; line-height: 1.4; color: var(--text); }
.patent-card .meta { color: var(--muted); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.patent-card .abs { color: #c4b5d6; font-size: 13px; margin-top: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.patent-card .pc-body { display: flex; gap: 12px; align-items: flex-start; margin-top: 8px; }
.patent-card .pc-img { flex-shrink: 0; width: 110px; }
.patent-card .pc-img img { width: 100%; height: auto; border: 1px solid var(--border-strong); border-radius: 4px; display: block; }
.patent-card .pc-body .abs { margin-top: 0; flex: 1; min-width: 0; -webkit-line-clamp: 3; }
.patent-card .pc-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ===================== Detail drawer ===================== */
.drawer-mask { position: fixed; inset: 0; background: rgba(8,5,20,.6); backdrop-filter: blur(3px); z-index: 40; display: none; }
.drawer-mask.open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 640px; max-width: 94vw;
  background: linear-gradient(180deg, rgba(30,23,58,0.95), rgba(22,16,44,0.92));
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-left: 1px solid var(--border-strong); box-shadow: -8px 0 32px rgba(8,5,20,.5); z-index: 41;
  transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.drawer-body { padding: 18px 22px; overflow-y: auto; flex: 1; }
.drawer-body h4 { margin: 18px 0 8px; font-size: 13.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.claim { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px; white-space: pre-wrap; font-size: 13px; color: var(--text); }

/* ===================== Disclosure / Draft editor ===================== */
.split { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.doc-list { max-height: 72vh; overflow-y: auto; }
.doc-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px;
  cursor: pointer; transition: border .15s, background .15s; background: var(--surface);
}
.doc-item:hover { border-color: var(--primary-100); background: var(--surface-2); }
.doc-item.active { border-color: var(--primary); background: var(--primary-50); box-shadow: var(--glow-soft); }
.doc-item .doc-idx { flex: 0 0 auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px; background: var(--primary-50); color: #93c5fd; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; margin-top: 1px; }
.doc-item.active .doc-idx { background: var(--primary-grad); color: #fff; }
.doc-item .doc-body { flex: 1 1 auto; min-width: 0; }
.doc-item .t { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.doc-item .m { color: var(--muted); font-size: 11.5px; margin-top: 3px; }
.editor-toolbar { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--border-strong); border-bottom: none; border-radius: var(--radius-sm) var(--radius-sm) 0 0; background: var(--surface-2); }
.editor-toolbar button { border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 4px 9px; font-size: 12.5px; cursor: pointer; color: var(--text); }
.editor-toolbar button:hover { background: var(--primary-50); border-color: var(--primary); }
.editor-wrap textarea { border-radius: 0 0 var(--radius-sm) var(--radius-sm); min-height: 160px; font-family: var(--mono); background: rgba(15,10,30,0.55); }
.section-block { margin-bottom: 16px; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

/* ===================== Materials upload ===================== */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface-2); padding: 30px 20px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.dropzone:hover { border-color: var(--primary); background: var(--primary-50); box-shadow: var(--glow-soft); }
.dropzone.dragover { border-color: var(--primary); background: var(--primary-50); }
.dz-ico { font-size: 30px; margin-bottom: 8px; }
.dz-title { font-weight: 600; font-size: 14px; color: var(--text); }
.dz-sub { margin-top: 4px; color: var(--muted); }
.mat-list { display: flex; flex-direction: column; gap: 8px; }
.mat-item {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; background: var(--surface);
}
.mat-item:hover { border-color: var(--primary-100); }
.mat-ic { font-size: 20px; flex-shrink: 0; width: 26px; text-align: center; }
.mat-main { flex: 1; min-width: 0; }
.mat-name { font-weight: 600; font-size: 13.5px; word-break: break-all; color: var(--text); }
.mat-meta { margin-top: 2px; color: var(--muted); }
.progress { height: 8px; background: rgba(15,10,30,0.6); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent-grad); border-radius: 999px; transition: width .2s ease; box-shadow: 0 0 10px rgba(99,102,241,0.5); }
.mat-item .progress { height: 5px; margin-top: 6px; }
.mat-status { min-width: 110px; text-align: right; font-size: 12px; white-space: nowrap; color: var(--muted); }

/* ===================== Toast ===================== */
.toast-wrap { position: fixed; bottom: 22px; right: 22px; z-index: 60; display: flex; flex-direction: column; gap: 10px; }
.toast { background: rgba(20,14,40,0.9); color: var(--text); padding: 11px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow-md); border: 1px solid var(--border-strong); animation: slidein .2s ease; max-width: 320px; backdrop-filter: blur(8px); }
.toast.ok { background: rgba(6,78,59,0.9); border-color: rgba(52,211,153,0.4); color: #d1fae5; }
.toast.err { background: rgba(127,29,29,0.9); border-color: rgba(251,113,133,0.4); color: #fecdd3; }
@keyframes slidein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===================== Misc ===================== */
.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.search-layout > .empty { flex: 1; text-align: center; }
.empty .big { font-size: 34px; margin-bottom: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 6px 10px; font-size: 13px; }
.kv .k { color: var(--muted); }
.divider { height: 1px; background: var(--border); margin: 14px 0; }

/* ===================== 工作台 · 模块总览 ===================== */
.section-title { font-size: 15px; font-weight: 700; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; color: var(--text); }
.mod-group { margin-bottom: 18px; }
.mod-group-title { font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 2px 2px 12px; letter-spacing: .4px; text-transform: uppercase; }
.mod-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 980px) { .mod-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .mod-grid { grid-template-columns: 1fr; } }
.mod-card {
  display: flex; flex-direction: column; gap: 10px; min-height: 118px;
  background: var(--surface); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: border .15s, box-shadow .15s, transform .12s, background .15s;
  position: relative; overflow: hidden;
}
.mod-card::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px;
  background: radial-gradient(circle, rgba(59,130,246,0.22), transparent 70%);
  opacity: 0; transition: opacity .2s;
}
.mod-card:hover { border-color: var(--border-strong); box-shadow: var(--glow); transform: translateY(-2px); background: var(--surface-2); }
.mod-card:hover::after { opacity: 1; }
.mod-ico {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: var(--primary-50); color: #93c5fd; font-size: 19px;
  box-shadow: inset 0 0 12px rgba(59,130,246,0.3);
}
.mod-body { flex: 1; }
.mod-title { font-weight: 700; font-size: 14.5px; display: flex; align-items: center; gap: 6px; color: var(--text); }
.mod-arrow { color: var(--primary); font-weight: 700; transition: transform .15s; }
.mod-card:hover .mod-arrow { transform: translateX(4px); }
.mod-desc { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin-top: 4px; }
.mod-foot { margin-top: auto; }
.mod-badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--primary-50); color: #93c5fd; }
.mod-badge.ok { background: var(--success-bg); color: var(--success); }
.mod-badge.off { background: var(--danger-bg); color: var(--danger); }
.status-line { font-size: 13px; color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab { padding: 9px 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; transition: color .15s, border-color .15s; }
.tab.active { color: #93c5fd; border-bottom-color: var(--primary); }
.preview { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px 20px; font-size: 13.5px; line-height: 1.75; color: var(--text); }
.preview h1, .preview h2, .preview h3 { line-height: 1.4; color: var(--text); }
.preview ul { padding-left: 20px; }
.preview code { background: rgba(59,130,246,0.18); padding: 1px 5px; border-radius: 4px; color: #b1c5f0; }
.pill-toggle { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.pill-toggle button { border: none; background: transparent; padding: 5px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; transition: all .15s; }
.pill-toggle button.active { background: var(--primary-50); color: #93c5fd; box-shadow: var(--glow-soft); }
.loader { text-align: center; color: var(--muted); padding: 30px; }

/* ===================== AI 撰写面板 ===================== */
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.ai-panel { border: 1px solid var(--border-strong); background: linear-gradient(180deg, var(--primary-50), var(--surface) 60%); box-shadow: var(--glow-soft); }
.ai-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; gap: 10px; }
.ai-panel-title { font-size: 15px; font-weight: 700; color: #93c5fd; }
.mat-picks { display: flex; flex-wrap: wrap; gap: 8px; }
.mat-pick { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 12.5px; cursor: pointer; color: var(--text); }
.mat-pick:hover { border-color: var(--primary); }
.mat-pick input { margin: 0; accent-color: var(--primary); }
.patent-chk, #selectAllChk { accent-color: var(--primary); }
.mat-idx { flex: 0 0 auto; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 6px; background: var(--primary-50); color: #93c5fd; font-size: 11.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; margin-top: 1px; }
.mat-pick .mat-idx { margin-right: -2px; }
.ai-tasks { margin-top: 6px; border-top: 1px dashed var(--border); padding-top: 8px; }
.ai-task { display: flex; align-items: center; gap: 8px; padding: 6px 0; flex-wrap: wrap; }
.ai-task-title { font-weight: 600; font-size: 13px; color: var(--text); }
.ai-task-meta { color: var(--muted); font-size: 12px; }
.ai-live {
  margin: 10px 0 0; padding: 12px 14px; max-height: 360px; overflow: auto;
  background: #0c0a1e; color: #cbd5e1; border-radius: 10px; border: 1px solid var(--border-strong);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7; white-space: pre-wrap; word-break: break-word;
  box-shadow: inset 0 0 20px rgba(59,130,246,0.12);
}
.ai-live::before { content: "● 生成中（实时）"; display: block; color: #67e8f9; font-size: 11px; margin-bottom: 6px; letter-spacing: .04em; text-shadow: 0 0 8px rgba(103,232,249,0.6); }

/* 权利要求书 */
.claims-block .claim { margin: 0 0 12px; line-height: 1.9; text-align: justify; text-indent: 0; padding-left: 2em; position: relative; }
.claims-block .claim .sub { display: block; text-indent: 2em; }
.doc-preview h1 { text-align: center; font-size: 20px; margin: 4px 0 18px; color: var(--text); }
.doc-preview h2 { font-size: 16px; margin: 22px 0 10px; padding-left: 8px; border-left: 4px solid var(--primary); font-weight: 700; color: var(--text); }
.spec-block { line-height: 1.9; color: var(--text); }

/* 本地专利库查新 */
.prior-art { margin: 0 0 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.prior-art .pa-cap { font-weight: 700; font-size: 13px; margin-bottom: 10px; color: #93c5fd; }
.prior-art .pa-item { padding: 8px 0; border-top: 1px dashed var(--border); }
.prior-art .pa-item:first-of-type { border-top: none; }
.prior-art .pa-h { display: flex; gap: 8px; align-items: baseline; }
.prior-art .pa-no { flex: none; width: 18px; height: 18px; line-height: 18px; text-align: center; font-size: 11px; border-radius: 50%; background: var(--primary-grad); color: #fff; }
.prior-art .pa-title { font-weight: 600; font-size: 13px; color: var(--text); }
.prior-art .pa-meta { font-size: 12px; color: var(--muted); margin: 3px 0 0 26px; }
.prior-art .pa-abs { font-size: 12px; color: var(--text); margin: 4px 0 0 26px; line-height: 1.6; }

/* ===================== 知识库 ===================== */
.kb-search { display: flex; gap: 8px; align-items: center; }
.kb-search-ico { font-size: 18px; }
.kb-search input { flex: 1; padding: 11px 14px; font-size: 15px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: rgba(15,10,30,0.45); color: var(--text); }
.kb-search-head { margin: 4px 0 12px; font-size: 14px; color: var(--muted); }
.kb-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (max-width: 880px) { .kb-grid { grid-template-columns: 1fr; } }
.kb-cat .kb-count { font-size: 12px; color: var(--muted); margin-left: 6px; font-weight: 400; }
.kb-item { padding: 9px 8px; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid transparent; }
.kb-item:hover { background: var(--surface-2); border-color: var(--border); }
.kb-item .t { font-weight: 600; font-size: 13px; line-height: 1.45; color: var(--text); }
.kb-item .m { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kb-item .kb-ftag { display:inline-block; font-size:10.5px; font-weight:600; color:#93c5fd; background:var(--primary-50); border-radius:5px; padding:1px 6px; margin-left:6px; vertical-align:middle; }
.kb-item .kb-snip { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.5; border-left: 2px solid var(--border-strong); padding-left: 8px; }
.kb-grp-title { font-weight: 700; font-size: 14px; margin-bottom: 8px; color: var(--text); }

/* ===================== 后台生成悬浮面板 ===================== */
.gen-float {
  position: fixed; right: 18px; bottom: 18px; z-index: 1200;
  width: 380px; max-width: calc(100vw - 36px);
  display: flex; flex-direction: column;
  background: rgba(24,18,46,0.94); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 14px 44px rgba(8,5,20,.5);
  overflow: hidden;
  font-size: 13px;
}
.gen-float-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: linear-gradient(180deg, var(--primary-50), rgba(24,18,46,0.6));
  border-bottom: 1px solid var(--border);
}
.gen-ico { font-size: 16px; }
.gen-title { font-weight: 700; color: #f3e8ff; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gen-status { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.gen-status.st-running { color: #93c5fd; background: rgba(59,130,246,0.22); }
.gen-status.st-paused { color: #fcd34d; background: rgba(251,191,36,0.18); }
.gen-status.st-done { color: #6ee7b7; background: rgba(52,211,153,0.18); }
.gen-status.st-error { color: #fecdd3; background: rgba(251,113,133,0.18); }
.gen-status.st-cancelled { color: #a9a3c4; background: rgba(122,112,153,0.18); }
.gen-x { border: none; background: rgba(255,255,255,0.06); color: var(--muted); cursor: pointer; width: 24px; height: 24px; border-radius: 7px; font-size: 13px; line-height: 1; }
.gen-x:hover { background: rgba(255,255,255,0.14); }
.gen-preview {
  margin: 0; padding: 10px 12px; max-height: 240px; overflow: auto;
  background: #0c0a1e; color: #e2e8f0;
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word; border-bottom: 1px solid var(--border);
}
.gen-foot { display: flex; align-items: center; gap: 8px; padding: 10px 12px; flex-wrap: wrap; }
.gen-err { color: #fecdd3; font-size: 12px; margin-right: auto; }

/* ===================== 检索筛选栏 ===================== */
.search-layout { display: flex; gap: 16px; align-items: flex-start; }
.search-sidebar { flex: 0 0 260px; max-height: calc(100vh - 100px); overflow-y: auto; position: sticky; top: 76px; }
.search-sidebar .fsec { margin-bottom: 14px; }
.search-sidebar .fsec h4 { margin: 0 0 6px; font-size: 13px; color: var(--text); }
.search-sidebar .fopt { display: block; padding: 3px 6px; font-size: 12px; cursor: pointer; border-radius: 4px; color: var(--text); text-decoration: none; line-height: 1.6; }
.search-sidebar .fopt:hover { background: var(--surface-2); }
.search-sidebar .fopt .c { float: right; color: var(--muted); font-size: 11px; }
.search-sidebar .fopt.active { background: rgba(99,102,241,0.22); color: #93c5fd; font-weight: 600; }
.search-sidebar .fopt.excluded { opacity: .4; text-decoration: line-through; }
.search-main { flex: 1; min-width: 0; }

/* ===================== 分页 ===================== */
.pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin: 8px 0; }
.pagination .btn { min-width: 32px; text-align: center; }
.pagination .btn[disabled] { opacity: .4; cursor: default; }
.gen-float.collapsed .gen-preview { display: none; }

/* ===================== 首页趋势图 ===================== */
.trend-card { background: var(--surface); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px 18px; margin-bottom: 22px; position: relative; overflow: hidden; }
.trend-card::before { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; background: radial-gradient(circle, rgba(59,130,246,0.18), transparent 70%); }
.trend-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.trend-title { font-size: 15px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.trend-title .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 8px var(--success); animation: pulse 1.6s infinite; }
.trend-sub { font-size: 12px; color: var(--muted); }
.trend-chart { width: 100%; height: 240px; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ===================== 页面切换动画 ===================== */
.view-enter { animation: viewFadeUp .38s ease-out both; }
@keyframes viewFadeUp {
  0% { opacity: 0; transform: translateY(14px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  0% { opacity: 0; transform: translateX(20px); }
  100% { opacity: 1; transform: translateX(0); }
}

/* ===================== 微流控通道粒子 ===================== */
.app-bg-particles { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.app-particle {
  position: absolute; width: 3px; height: 3px; border-radius: 50%;
  background: rgba(59,130,246,0.5); box-shadow: 0 0 6px rgba(59,130,246,0.4);
  animation: particleFlow var(--dur, 12s) linear infinite;
  animation-delay: var(--delay, 0s);
}
.app-particle:nth-child(1) { --x: 10%; --y: 20%; --x2: 65%; --y2: 40%; --dur: 14s; --delay: -2s; width: 2px; height: 2px; }
.app-particle:nth-child(2) { --x: 15%; --y: 35%; --x2: 55%; --y2: 55%; --dur: 18s; --delay: -5s; width: 4px; height: 4px; background: rgba(34,211,238,0.45); box-shadow: 0 0 8px rgba(34,211,238,0.35); }
.app-particle:nth-child(3) { --x: 5%; --y: 15%; --x2: 70%; --y2: 30%; --dur: 16s; --delay: -8s; }
.app-particle:nth-child(4) { --x: 8%; --y: 50%; --x2: 75%; --y2: 65%; --dur: 20s; --delay: -3s; width: 2px; height: 2px; background: rgba(6,182,212,0.45); box-shadow: 0 0 6px rgba(6,182,212,0.3); }
.app-particle:nth-child(5) { --x: 20%; --y: 10%; --x2: 60%; --y2: 45%; --dur: 15s; --delay: -10s; width: 3px; height: 3px; background: rgba(129,140,248,0.6); box-shadow: 0 0 8px rgba(129,140,248,0.4); }
.app-particle:nth-child(6) { --x: 12%; --y: 60%; --x2: 80%; --y2: 50%; --dur: 22s; --delay: -6s; }
.app-particle:nth-child(7) { --x: 25%; --y: 45%; --x2: 50%; --y2: 70%; --dur: 13s; --delay: -1s; width: 2px; height: 2px; background: rgba(34,211,238,0.5); }
.app-particle:nth-child(8) { --x: 3%; --y: 30%; --x2: 85%; --y2: 35%; --dur: 19s; --delay: -12s; width: 4px; height: 4px; }
@keyframes particleFlow {
  0% { left: var(--x); top: var(--y); opacity: 0; }
  10% { opacity: 1; }
  85% { opacity: 1; }
  100% { left: var(--x2); top: var(--y2); opacity: 0; }
}

/* 沙漏动画 */
@keyframes hourglassSpin {
  0% { transform: rotate(0deg); }
  50% { transform: rotate(180deg); }
  100% { transform: rotate(180deg); }
}
@keyframes genPulse {
  0%,100% { opacity: 1; }
  50% { opacity: .6; }
}
.gen-hourglass {
  animation: hourglassSpin 2s ease-in-out infinite;
}
.gen-hourglass + span {
  animation: genPulse 1.5s ease-in-out infinite;
}

/* ===================== 分栏编辑器 ===================== */
.split-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; min-height: 400px; }
.split-edit { overflow-y: auto; max-height: calc(100vh - 300px); padding-right: 6px; }
.split-preview { overflow-y: auto; max-height: calc(100vh - 300px); border-left: 1px solid var(--border); padding-left: 14px; }
.split-preview .preview { font-size: 13px; line-height: 1.7; }
.tb-sep { display: inline-block; width: 1px; height: 16px; background: var(--border); margin: 0 2px; vertical-align: middle; }

/* ===================== 登录页 ===================== */
.view:has(.login-wrap) { height: 100%; display: flex; flex-direction: column; }
.login-wrap { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; background: radial-gradient(ellipse at 30% 40%, rgba(59,130,246,0.10), transparent 60%), radial-gradient(ellipse at 70% 60%, rgba(6,182,212,0.08), transparent 50%); }
.login-wrap::before { content: ''; position: absolute; inset: 0; background: url('../img/microfluidic-bg.svg') center/cover; opacity: .08; pointer-events: none; }
.login-card { width: 460px; padding: 42px 40px 30px; position: relative; z-index: 1; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid rgba(59,130,246,0.25); box-shadow: 0 0 60px rgba(59,130,246,0.12), var(--shadow-md); animation: viewFadeUp .6s ease-out both; }
.login-brand { text-align: center; }
.login-logo { font-size: 56px; font-weight: 800; background: linear-gradient(135deg, #60a5fa, #22d3ee); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; letter-spacing: 3px; margin-bottom: 28px; }
.login-sub { font-size: 14px; color: var(--muted); margin-top: 4px; letter-spacing: 1px; }
.login-desc { text-align: center; font-size: 13px; color: var(--muted); margin: 16px 0 20px; line-height: 1.6; }
.login-input { display: block; width: 100%; padding: 14px 18px; font-size: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: rgba(21,16,46,0.6); color: var(--text); outline: none; box-sizing: border-box; transition: box-shadow .3s, border-color .3s; }
.login-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.2), 0 0 16px rgba(59,130,246,0.15); }
.login-btn { display: block; width: 100%; margin-top: 14px; padding: 14px; font-size: 16px; font-weight: 700; transition: all .3s; position: relative; overflow: hidden; }
.login-err { min-height: 18px; text-align: center; margin-top: 8px; font-size: 13px; color: #f87171; }
.login-hints { text-align: center; margin-top: 16px; line-height: 1.8; font-size: 13px; color: var(--muted); }
.login-pw-badge { display: inline-block; font-size: 15px; font-weight: 800; color: #fff; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.12); border-radius: 4px; padding: 1px 8px; letter-spacing: 1px; margin: 0 1px; }
.login-card .btn.primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(59,130,246,0.4); }
.login-card .btn.primary:active { transform: translateY(0); }

/* ===================== Toggle 开关（微流控模式等） ===================== */
.toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.toggle input[type="checkbox"] { display: none; }
.toggle .toggle-slider { position: relative; width: 36px; height: 20px; background: var(--border-strong); border-radius: 10px; transition: background .3s; flex: none; }
.toggle .toggle-slider::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .3s; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.toggle input:checked + .toggle-slider { background: linear-gradient(135deg, #3b82f6, #22d3ee); }
.toggle input:checked + .toggle-slider::after { transform: translateX(16px); }

/* ===================== 细节动效 ===================== */
/* 按钮悬停辉光 */
.btn:not(.ghost):hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(59,130,246,0.3); transition: all .25s; }
.btn.ghost:hover { background: rgba(59,130,246,0.12); }
.btn.primary:hover { box-shadow: 0 4px 20px rgba(59,130,246,0.45); }

/* 统计数字动画 */
.stat { transition: transform .3s, box-shadow .3s; }
.stat:hover { transform: translateY(-3px); box-shadow: 0 8px 32px rgba(0,0,0,0.25); }
.stat .n { display: inline-block; }
.stat:hover .n { animation: countPop .4s ease-out; }
@keyframes countPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* 模块卡片入场交错 */
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.mod-card { animation: viewFadeUp .45s ease-out both; transition: transform .3s, box-shadow .3s, border-color .3s; }
.mod-card:hover { transform: translateY(-4px); box-shadow: 0 12px 36px rgba(0,0,0,0.3); border-color: rgba(59,130,246,0.35); }
.mod-card:nth-child(1) { animation-delay: .02s; }
.mod-card:nth-child(2) { animation-delay: .06s; }
.mod-card:nth-child(3) { animation-delay: .10s; }
.mod-card:nth-child(4) { animation-delay: .14s; }
.mod-card:nth-child(5) { animation-delay: .18s; }
.mod-card:nth-child(6) { animation-delay: .22s; }
.mod-card:nth-child(7) { animation-delay: .26s; }
.mod-card:nth-child(8) { animation-delay: .30s; }

/* 侧边栏呼吸光效 */
.nav-item.active { position: relative; }
.nav-item.active::after { content: ''; position: absolute; right: -1px; top: 6px; bottom: 6px; width: 2px; background: linear-gradient(to bottom, #3b82f6, #06b6d4); border-radius: 2px; box-shadow: 0 0 10px rgba(59,130,246,0.6); animation: glowBreathe 2.4s ease-in-out infinite; }
@keyframes glowBreathe {
  0%,100% { box-shadow: 0 0 10px rgba(59,130,246,0.5); }
  50% { box-shadow: 0 0 18px rgba(59,130,246,0.8), 0 0 30px rgba(6,182,212,0.3); }
}

/* 顶部光带效果 */
.topbar::after { content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 1px; background: linear-gradient(90deg, transparent 0%, rgba(59,130,246,0.3) 20%, rgba(34,211,238,0.3) 50%, rgba(59,130,246,0.3) 80%, transparent 100%); animation: scanLine 4s linear infinite; background-size: 200% 100%; }
@keyframes scanLine {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.topbar { position: relative; }

/* ===================== 专利地图卡片 ===================== */
.map-card { background: var(--surface); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px 18px; margin-bottom: 22px; position: relative; overflow: hidden; animation: viewFadeUp .5s ease-out both; animation-delay: .35s; }
.map-card::before { content: ""; position: absolute; left: -60px; bottom: -60px; width: 200px; height: 200px; background: radial-gradient(circle, rgba(34,211,238,0.1), transparent 70%); }
.map-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.map-title { font-size: 15px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.map-chart { width: 100%; min-height: 200px; }

/* ===================== 移动端适配（≤820px） ===================== */
.topbar-left { display: flex; align-items: center; gap: 10px; }
.mobile-menu-btn {
  display: none;
  align-items: center; justify-content: center;
  width: 40px; height: 40px; flex-shrink: 0;
  border: 1px solid transparent; border-radius: 10px;
  background: var(--primary-grad); color: #fff;
  font-size: 20px; line-height: 1; cursor: pointer;
  box-shadow: 0 2px 10px rgba(59,130,246,0.45);
}
.sidebar-mask {
  display: none;
  position: fixed; inset: 0;
  background: rgba(8,5,20,0.55);
  opacity: 0; pointer-events: none;
  transition: opacity .28s ease;
  z-index: 45;
}
.sidebar-mask.show { opacity: 1; pointer-events: auto; }

@media (max-width: 820px) {
  .layout { display: block; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: 240px; max-width: 82vw; height: 100%;
    transform: translateX(-100%);
    transition: transform .28s ease;
    z-index: 50;
    box-shadow: 6px 0 30px rgba(8,5,20,0.5);
  }
  .sidebar.open { transform: translateX(0); }
  /* 移动端忽略桌面折叠宽度，始终显示完整侧边栏 */
  .sidebar.collapsed { width: 240px; }
  .sidebar.collapsed .nav-item span:not(.ico) { display: inline; }
  .sidebar.collapsed .brand > .logo + div { display: block; }
  .sidebar.collapsed .nav-group-title .g-label { display: inline; }
  .sidebar.collapsed .nav-group-title .caret { display: inline; }
  .sidebar.collapsed .nav-group-items { display: block; }

  .main { width: 100%; }
  .topbar { padding: 0 14px; height: 56px; }
  .topbar h1 { font-size: 16px; }
  .topbar .crumb { display: none; }
  .content { padding: 16px; }
  .mobile-menu-btn { display: inline-flex; }
  .sidebar-mask { display: block; }
  .sidebar-toggle { display: none; }
  .card-pad { padding: 14px 14px; }
  .row { flex-wrap: wrap; }
  /* 表格/列表横向滚动，避免溢出 */
  .table-wrap, .scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* 地图全宽、收窄高度：避免中国地图（宽幅）在竖屏上下留白显得小 */
  #panChinaMap { height: 52vh !important; min-height: 240px !important; max-height: 460px !important; }
  #chinaMap { width: 100% !important; min-width: 0 !important; flex: none !important; height: 56vh !important; max-height: 520px !important; }
  #geoSide { width: 100% !important; min-width: 0 !important; max-height: none !important; }
  .geo-flex { flex-direction: column !important; gap: 12px !important; }
  .topbar-left { gap: 12px; }
}

/* AI 对话思考中打字动画 */
@keyframes typingDot { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.typing-dot { width: 6px; height: 6px; border-radius: 50%; background: #93c5fd; display: inline-block; margin: 0 2px; animation: typingDot 1.2s ease-in-out infinite; }
.typing-dot:nth-child(2) { animation-delay: .15s; }
.typing-dot:nth-child(3) { animation-delay: .3s; }
