:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-subtle: #f1f0ec;
  --surface-hover: #eae8e1;
  --border: #e4e1d9;
  --border-strong: #cfc9bc;
  --text: #1c1b18;
  --text-muted: #5e5b52;
  --text-faint: #8c877c;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --accent-text: #1d4ed8;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --success: #059669;
  --success-soft: #d1fae5;
  --danger: #dc2626;
  --purple: #7c3aed;
  --shadow-sm: 0 1px 2px rgba(28, 27, 24, 0.05);
  --shadow-md: 0 6px 20px rgba(28, 27, 24, 0.08);
  --shadow-lg: 0 18px 48px rgba(28, 27, 24, 0.16);
  --radius-sm: 7px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --sidebar-w: 256px;
  --topbar-h: 56px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.3, 0.64, 1);
  --font-sans: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #121316;
  --surface: #1a1c21;
  --surface-subtle: #22252c;
  --surface-hover: #2a2e37;
  --border: #2c313b;
  --border-strong: #414856;
  --text: #eceef2;
  --text-muted: #a4abb8;
  --text-faint: #737b8c;
  --accent: #60a5fa;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --accent-text: #93c5fd;
  --warn: #fbbf24;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --success: #34d399;
  --success-soft: rgba(16, 185, 129, 0.14);
  --danger: #f87171;
  --purple: #a78bfa;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.65);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
  transition: background-color 220ms ease, color 220ms ease;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

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

@keyframes msgEnter {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes pulseDot {
  0%, 80%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1.1);
  }
}

.view-enter {
  animation: viewEnter 220ms var(--ease-out) both;
}

/* 顶部主导航 */
.topbar {
  height: var(--topbar-h);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 12px;
  transition: background-color 220ms ease, border-color 220ms ease;
}

[data-theme="dark"] .topbar {
  background: rgba(26, 28, 33, 0.9);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.brand-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14.5px;
  cursor: pointer;
  flex-shrink: 0;
  padding-right: 6px;
}

.brand-logo {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}

.domain-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 0 2px 10px;
  border-left: 1px solid var(--border);
}

.domain-tabs::-webkit-scrollbar {
  display: none;
}

.domain-tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background-color 160ms ease, color 160ms ease, transform 120ms var(--ease-out);
}

.domain-tab:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.domain-tab:active {
  transform: scale(0.96);
}

.domain-tab.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 150ms ease, color 150ms ease, transform 120ms var(--ease-out);
}

.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.icon-btn:active {
  transform: scale(0.93);
}

.search-trigger-btn {
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease, transform 120ms var(--ease-out);
}

.search-trigger-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.search-kbd {
  font-size: 11px;
  color: var(--text-faint);
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 4px;
  padding: 0 5px;
  line-height: 1.4;
}

.pill-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 120ms var(--ease-out), box-shadow 150ms ease;
}

.pill-btn:hover {
  background: var(--surface-subtle);
}

.pill-btn:active {
  transform: scale(0.96);
}

.pill-btn.active {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-text);
}

.pill-btn.primary {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  border-color: transparent;
  color: #fff;
}

.pill-btn.primary:hover {
  opacity: 0.94;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 11px;
  font-weight: 700;
}

/* 边栏（固定内宽滑出不挤字） */
.app-shell {
  display: flex;
  min-height: calc(100vh - var(--topbar-h));
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: transparent;
  border-right: 1px solid var(--border);
  height: calc(100vh - var(--topbar-h));
  position: sticky;
  top: var(--topbar-h);
  z-index: 40;
  overflow: hidden;
  transition: width 240ms var(--ease-out), border-color 200ms ease, opacity 180ms ease;
}

.sidebar-inner {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100%;
  display: flex;
  flex-direction: column;
  transition: transform 240ms var(--ease-out);
}

.sidebar.collapsed {
  width: 0;
  border-right-color: transparent;
  opacity: 0;
  pointer-events: none;
}

.sidebar.collapsed .sidebar-inner {
  transform: translateX(-24px);
}

.sidebar-mobile-header,
.mobile-domain-pills,
.mobile-drawer-tools {
  display: none;
}

.sidebar-domain-head {
  padding: 20px 18px 10px;
}

.sidebar-domain-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sidebar-domain-sub {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 2px;
}

.tree-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 6px 12px 24px;
}

.nav-section {
  margin-top: 14px;
}

.nav-section:first-child {
  margin-top: 4px;
}

.nav-section-title {
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 0.03em;
}

.nav-leaf-btn {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin: 2px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--text-muted);
  transition: background-color 150ms ease, color 150ms ease, transform 130ms var(--ease-out), box-shadow 150ms ease, border-color 150ms ease;
}

.nav-leaf-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  transform: translateX(2px);
}

.nav-leaf-btn.active {
  background: var(--surface);
  color: var(--accent-text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  border-color: var(--border);
  transform: translateX(0);
}

.sidebar-empty {
  margin: 14px 8px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* 主阅读区 */
.main-wrap {
  flex: 1;
  min-width: 0;
}

.content-area {
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 30px 88px;
}

.article-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-faint);
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.breadcrumb-current {
  color: var(--text-muted);
  font-weight: 600;
}

.note-header {
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.note-meta-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.eli5-pill {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
}

.note-title {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.28;
  letter-spacing: -0.02em;
}

.note-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 15.5px;
}

.eli5-card {
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin: 18px 0;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface) 60%);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  box-shadow: var(--shadow-sm);
}

.eli5-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-text);
  margin-bottom: 8px;
}

.eli5-story {
  font-size: 15.5px;
  line-height: 1.75;
}

.callout {
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin: 16px 0;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.callout.context {
  border-left: 4px solid var(--purple);
}

.callout.scenario {
  border-left: 4px solid var(--success);
}

.callout-title {
  font-weight: 700;
  font-size: 13.5px;
  margin-bottom: 6px;
}

.section-heading {
  margin: 30px 0 12px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Markdown 内容渲染风格 */
.md-body p {
  margin: 0 0 10px;
}
.md-body p:last-child {
  margin-bottom: 0;
}
.md-body ul,
.md-body ol {
  margin: 6px 0 10px;
  padding-left: 20px;
}
.md-body li {
  margin: 4px 0;
}
.md-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
}
.md-body pre {
  margin: 10px 0;
  padding: 12px 14px;
  background: #18181b;
  color: #f4f4f5;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
}
.md-body pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
}
.md-body h3,
.md-body h4 {
  margin: 12px 0 6px;
  font-size: 15px;
}
.md-body blockquote {
  margin: 8px 0;
  padding: 6px 12px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-muted);
  background: var(--surface-subtle);
  border-radius: 0 6px 6px 0;
}

.md-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 6px 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 520px;
}

.md-table th,
.md-table td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.md-table thead th {
  background: var(--surface-subtle);
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.md-table tbody tr:last-child td {
  border-bottom: none;
}

.md-table tbody tr:hover {
  background: var(--surface-subtle);
}

.specs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.lab-action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: -4px 0 12px;
}

.token-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.token-chip {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease, transform 120ms ease;
}

.token-chip:hover {
  background: var(--surface-subtle);
}

.token-chip:active {
  transform: scale(0.95);
}

.token-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* 平滑折叠动画 */
.collapse-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  overflow: hidden;
}

.collapse-box.is-extension {
  border-left: 3px solid var(--success);
}

.collapse-trigger {
  width: 100%;
  border: none;
  background: transparent;
  padding: 13px 16px;
  text-align: left;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  transition: background-color 150ms ease;
}

.collapse-trigger:hover {
  background: var(--surface-subtle);
}

.collapse-trigger.is-formula {
  background: var(--surface-subtle);
}

.collapse-arrow {
  display: inline-block;
  font-size: 12px;
  color: var(--text-faint);
  transition: transform 220ms var(--ease-out);
  flex-shrink: 0;
}

.collapse-box.open .collapse-arrow {
  transform: rotate(180deg);
}

.collapse-body-grid {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 240ms var(--ease-out);
}

.collapse-box.open .collapse-body-grid {
  grid-template-rows: 1fr;
}

.collapse-body-inner {
  overflow: hidden;
}

.collapse-body-pad {
  padding: 12px 16px 14px;
  font-size: 13.5px;
  color: var(--text-muted);
  border-top: 1px dashed var(--border);
}

/* 公式块 */
.formula-card {
  padding: 16px 18px;
  border-top: 1px solid var(--border);
  overflow-x: auto;
}

.formula-main {
  font-family: "Cambria Math", "Times New Roman", Georgia, serif;
  font-size: 17.5px;
  text-align: center;
  padding: 6px 0 12px;
  border-bottom: 1px dashed var(--border);
  overflow-x: auto;
}

.formula-terms {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.term-item {
  background: var(--surface-subtle);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 13px;
}

.term-symbol {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-text);
  margin-bottom: 2px;
}

/* 交互实验室 */
.lab-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin: 18px 0;
  box-shadow: var(--shadow-md);
}

.lab-header {
  margin-bottom: 14px;
}

.lab-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  margin-bottom: 4px;
}

.lab-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.lab-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}

.control-group label {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 6px;
}

.control-val {
  font-family: var(--font-mono);
  color: var(--accent-text);
}

.control-group input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.lab-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.lab-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--bg);
}

.lab-panel-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lab-svg {
  width: 100%;
  height: auto;
  display: block;
}

.lab-insight {
  margin-top: 12px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  background: var(--surface-subtle);
  border-left: 3px solid var(--accent);
}

/* 易混点与批注 */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0;
}

.compare-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  transition: transform 180ms var(--ease-out), box-shadow 180ms ease;
}

.compare-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.compare-card h4 {
  margin: 0 0 6px;
  font-size: 14.5px;
}

.compare-card p {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

.quiz-list {
  display: flex;
  flex-direction: column;
}

.personal-note-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.personal-note-box textarea {
  width: 100%;
  min-height: 82px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  padding: 10px 12px;
  resize: vertical;
  outline: none;
  font-size: 13.5px;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.personal-note-box textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.personal-note-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-faint);
}

/* 层级全景与待深化 */
.hierarchy-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 18px;
}

.hierarchy-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}

.domain-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px;
  transition: transform 180ms var(--ease-out), box-shadow 180ms ease;
}

.domain-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.domain-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  margin-bottom: 10px;
}

.tree-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  background: var(--surface-subtle);
  padding: 1px 7px;
  border-radius: 999px;
}

.domain-branch {
  margin-top: 10px;
  padding-left: 10px;
  border-left: 2px solid var(--border);
}

.domain-branch-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.domain-leaf-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  border: none;
  background: var(--surface-subtle);
  padding: 6px 9px;
  margin: 4px 0;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
  transition: background-color 140ms ease, color 140ms ease, transform 120ms ease;
}

.domain-leaf-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
  transform: translateX(2px);
}

.domain-leaf-btn.planned {
  opacity: 0.72;
  cursor: default;
}

.domain-leaf-btn.planned:hover {
  background: var(--surface-subtle);
  color: inherit;
  transform: none;
}

.backlog-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--warn);
  border-radius: var(--radius-md);
  padding: 15px 16px;
  margin-bottom: 12px;
}

.backlog-meta {
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.backlog-q {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 6px;
}

.backlog-summary {
  font-size: 13.5px;
  color: var(--text-muted);
  background: var(--surface-subtle);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}

.text-link-btn {
  border: none;
  background: none;
  color: var(--accent-text);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 5px;
  border-radius: 4px;
}

/* 搜索弹窗 */
.search-modal {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(4px);
  align-items: flex-start;
  justify-content: center;
  padding: 72px 16px 20px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.search-modal.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.search-modal-card {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(-8px) scale(0.97);
  transition: transform 200ms var(--ease-out);
}

.search-modal.open .search-modal-card {
  transform: translateY(0) scale(1);
}

.search-modal-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.search-modal-input-row input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 15px;
}

.search-modal-results {
  max-height: 360px;
  overflow-y: auto;
  padding: 8px;
}

.search-result-item {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: block;
  transition: background-color 140ms ease, transform 120ms ease;
}

.search-result-item:hover {
  background: var(--accent-soft);
  transform: translateX(2px);
}

.search-result-path {
  font-size: 11.5px;
  color: var(--text-faint);
}

.search-result-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* AI 抽屉 */
.ai-drawer {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  width: 410px;
  max-width: 100vw;
  height: calc(100vh - var(--topbar-h));
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 65;
  display: flex;
  flex-direction: column;
  transform: translateX(104%);
  transition: transform 260ms var(--ease-out);
}

.ai-drawer.open {
  transform: translateX(0);
}

.ai-drawer-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ai-context-bar {
  padding: 8px 16px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-msg {
  padding: 11px 13px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  line-height: 1.65;
  animation: msgEnter 200ms var(--ease-out) both;
}

.ai-msg.user {
  align-self: flex-end;
  max-width: 88%;
  background: var(--accent);
  color: #fff;
}

.ai-msg.assistant {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulseDot 1s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

.ai-msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.ai-mini-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, transform 120ms ease;
}

.ai-mini-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: transparent;
}

.ai-mini-btn:active {
  transform: scale(0.95);
}

.ai-mini-btn.done {
  background: var(--success-soft);
  color: var(--success);
  border-color: transparent;
}

.ai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px 0;
}

.ai-chip {
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  font-size: 11.5px;
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text-muted);
  transition: border-color 140ms ease, color 140ms ease, transform 120ms ease;
}

.ai-chip:hover {
  border-color: var(--accent);
  color: var(--accent-text);
}

.ai-input-wrap {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.ai-input-wrap textarea {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  padding: 8px 10px;
  font-size: 13px;
  resize: none;
  min-height: 40px;
  max-height: 96px;
  outline: none;
}

.ai-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 45;
  border: none;
  border-radius: 999px;
  padding: 11px 18px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  font-weight: 600;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: transform 180ms var(--ease-spring), box-shadow 180ms ease;
}

.ai-fab:hover {
  transform: translateY(-2px);
}

.ai-fab:active {
  transform: scale(0.95);
}

/* 访问口令遮罩 */
.lock-overlay {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(10px);
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 200ms ease, visibility 200ms ease;
}

.lock-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.lock-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 22px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  transform: scale(0.96) translateY(8px);
  transition: transform 220ms var(--ease-out);
}

.lock-overlay.open .lock-card {
  transform: scale(1) translateY(0);
}

.lock-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  margin: 14px 0 8px;
  text-align: center;
  font-size: 15px;
  outline: none;
}

.lock-card input:focus {
  border-color: var(--accent);
}

.lock-error {
  min-height: 20px;
  font-size: 12.5px;
  color: var(--danger);
  margin-bottom: 8px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  z-index: 45;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 220ms ease, visibility 220ms ease;
}

.drawer-backdrop.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.app-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 10px);
  opacity: 0;
  pointer-events: none;
  background: #18181b;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  transition: opacity 200ms ease, transform 200ms var(--ease-out);
  z-index: 98;
  max-width: 90vw;
  text-align: center;
}

.app-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* 窄屏分屏/平板适配 (<= 1120px) */
@media (max-width: 1120px) {
  .brand-name,
  .hide-on-compact {
    display: none !important;
  }
}

/* 手机端适配 */
@media (max-width: 768px) {
  .topbar {
    padding: 0 12px;
  }

  .domain-tabs,
  .hide-on-mobile {
    display: none !important;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: min(86vw, 310px) !important;
    background: var(--surface);
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: translateX(-102%);
    transition: transform 240ms var(--ease-out);
    box-shadow: var(--shadow-md);
    z-index: 60;
  }

  .sidebar-inner {
    width: 100%;
    min-width: 0;
    transform: none !important;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }

  .mobile-domain-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 14px 4px;
    flex-shrink: 0;
  }

  .mobile-domain-pills::-webkit-scrollbar {
    display: none;
  }

  .mobile-domain-pill {
    border: 1px solid var(--border);
    background: var(--surface-subtle);
    color: var(--text-muted);
    padding: 5px 11px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
  }

  .mobile-domain-pill.active {
    background: var(--accent-soft);
    border-color: transparent;
    color: var(--accent-text);
    font-weight: 600;
  }

  .mobile-drawer-tools {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    background: var(--surface);
  }

  .content-area {
    padding: 18px 14px 86px;
  }

  .note-title {
    font-size: 22px;
  }

  .lab-grid,
  .compare-grid {
    grid-template-columns: 1fr;
  }

  .lab-card {
    padding: 14px 12px;
  }

  .ai-drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 78vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 18px 18px 0 0;
    transform: translateY(104%);
    transition: transform 260ms var(--ease-out);
  }

  .ai-drawer.open {
    transform: translateY(0);
  }

  .ai-fab {
    right: 14px;
    bottom: 16px;
    padding: 10px 15px;
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
