/* ============================================================
   知行录 · 设计系统
   ============================================================ */
:root {
  --brand:        #4F46E5;
  --brand-light:  #6366F1;
  --brand-soft:   #EEF2FF;
  --brand-ring:   rgba(79, 70, 229, .18);

  --bg:           #F4F6FB;
  --card:         #FFFFFF;
  --border:       #E7ECF4;
  --border-2:     #D8E0EC;

  --text:         #0F172A;
  --text-2:       #475569;
  --text-3:       #94A3B8;

  --danger:       #EF4444;
  --danger-soft:  #FEF2F2;
  --success:      #16A34A;
  --warn:         #F59E0B;

  --r-xs: 8px;
  --r-sm: 10px;
  --r:    14px;
  --r-lg: 18px;
  --r-xl: 24px;

  --sh-1: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.05);
  --sh-2: 0 2px 6px rgba(15,23,42,.05), 0 8px 24px rgba(15,23,42,.06);
  --sh-3: 0 12px 40px rgba(15,23,42,.14);

  --sidebar-w: 268px;
  --topbar-h:  64px;
  --tabbar-h:  60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

.hidden, [hidden] { display: none !important; }

button { font-family: inherit; }

::selection { background: var(--brand-ring); }

/* 滚动条 */
.app-content::-webkit-scrollbar,
.sidebar-scroll::-webkit-scrollbar,
.search-results::-webkit-scrollbar,
.msearch-results::-webkit-scrollbar { width: 8px; height: 8px; }
.app-content::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb,
.msearch-results::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 99px; }
.app-content::-webkit-scrollbar-thumb:hover { background: #94A3B8; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 99px; }
.app-content::-webkit-scrollbar-track,
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   布局骨架
   ============================================================ */
.app-shell {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.app-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 26px max(28px, calc((100% - 1320px) / 2)) 60px;
  scroll-behavior: smooth;
}

/* ============================================================
   侧边栏
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(178deg, #131A2B 0%, #0C1120 60%, #0A0F1C 100%);
  color: #CBD5E1;
  position: relative;
  z-index: 60;
}
.sidebar::after {
  content: '';
  position: absolute;
  inset: 0 0 0 auto;
  width: 1px;
  background: rgba(255,255,255,.07);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-logo {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  font-size: 19px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand) 0%, #8B5CF6 100%);
  box-shadow: 0 6px 18px rgba(79,70,229,.45);
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { color: #fff; font-size: 15px; letter-spacing: .5px; line-height: 1.3; }
.brand-text small { color: #64748B; font-size: 11px; line-height: 1.3; }

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px;
}

.sidebar-section-title {
  padding: 4px 10px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #64748B;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-section-title button {
  background: none; border: 0; color: #64748B; cursor: pointer;
  width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center;
}
.sidebar-section-title button:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-section-title button svg { width: 14px; height: 14px; }

/* 知识库条目 */
.kb-group { margin-bottom: 2px; }

.sidebar-kb-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  color: #94A3B8;
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
  transition: background .16s, color .16s;
}
.sidebar-kb-item:hover { background: rgba(255,255,255,.06); color: #E2E8F0; }
.sidebar-kb-item.active {
  background: linear-gradient(90deg, rgba(79,70,229,.32), rgba(79,70,229,.08));
  color: #fff;
  box-shadow: inset 2px 0 0 var(--brand-light);
}
.sidebar-kb-item .kb-name {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-weight: 500;
}
.sidebar-kb-item .kb-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: .85; }
.kb-count {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 99px;
  background: rgba(255,255,255,.09);
  color: #94A3B8;
  flex-shrink: 0;
}
.sidebar-kb-item.active .kb-count { background: rgba(255,255,255,.2); color: #fff; }

.kb-caret {
  width: 18px; height: 18px;
  flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 5px;
  transition: transform .18s;
  opacity: .6;
}
.kb-caret svg { width: 11px; height: 11px; }
.kb-caret:hover { background: rgba(255,255,255,.12); opacity: 1; }
.kb-group.open > .sidebar-kb-item .kb-caret { transform: rotate(90deg); }

.kb-cats {
  display: none;
  margin: 2px 0 6px;
  padding-left: 18px;
  border-left: 1px solid rgba(255,255,255,.08);
  margin-left: 18px;
}
.kb-group.open > .kb-cats { display: block; }

.sidebar-cat-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border-radius: 7px;
  color: #7C8BA1;
  font-size: 12.5px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.sidebar-cat-item:hover { background: rgba(255,255,255,.05); color: #CBD5E1; }
.sidebar-cat-item.active { background: rgba(99,102,241,.18); color: #C7D2FE; }
.sidebar-cat-item .cat-dot {
  width: 5px; height: 5px; border-radius: 99px;
  background: currentColor; opacity: .55; flex-shrink: 0;
}
.sidebar-cat-item span.cat-name {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-empty {
  padding: 22px 14px;
  text-align: center;
  color: #64748B;
  font-size: 12.5px;
  line-height: 1.8;
}

.sidebar-foot {
  padding: 10px;
  border-top: 1px solid rgba(255,255,255,.07);
  display: grid;
  gap: 2px;
  padding-bottom: calc(10px + var(--safe-b));
}

.sidebar-footer-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  color: #94A3B8;
  font-size: 13px;
  text-decoration: none;
  transition: background .16s, color .16s;
}
.sidebar-footer-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-footer-link:hover { background: rgba(255,255,255,.06); color: #E2E8F0; }
.sidebar-footer-link.active { background: rgba(99,102,241,.2); color: #C7D2FE; font-weight: 500; }

.badge-dot {
  margin-left: auto;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: grid;
  place-items: center;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 22, .5);
  backdrop-filter: blur(2px);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}

/* ============================================================
   顶栏
   ============================================================ */
.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 max(20px, calc((100% - 1320px) / 2));
  background: rgba(255,255,255,.82);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 40;
}

.topbar-spacer { flex: 1; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  color: var(--text-3);
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.breadcrumb a { color: var(--text-2); text-decoration: none; border-radius: 6px; padding: 2px 4px; }
.breadcrumb a:hover { color: var(--brand); background: var(--brand-soft); }
.breadcrumb .crumb-current {
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.breadcrumb .crumb-sep { color: #CBD5E1; }

/* 搜索框 */
.search-box {
  position: relative;
  width: clamp(220px, 26vw, 380px);
}
.search-box .search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-3);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  height: 38px;
  padding: 0 112px 0 36px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: #F8FAFC;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.search-box input::placeholder { color: var(--text-3); }
.search-box input:focus {
  background: #fff;
  border-color: var(--brand-light);
  box-shadow: 0 0 0 4px var(--brand-ring);
}
.search-kbd {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  font-size: 10.5px;
  color: var(--text-3);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  pointer-events: none;
  font-family: inherit;
}
.search-box input:focus ~ .search-kbd { opacity: 0; }

/* ============================================================
   文章查看页（只读）
   ============================================================ */
.viewer-shell {
  max-width: 1160px;
  margin: 0 auto;
  background: #fff;
  border-radius: var(--r);
  border: 1px solid var(--border);
  box-shadow: var(--sh-2);
  overflow: hidden;
}
.viewer-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: #FBFCFE;
}
.viewer-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-danger-outline { color: var(--danger); border-color: #FECACA; }
.btn-danger-outline:hover { background: #FEF2F2; border-color: #FCA5A5; }

.viewer-article { padding: 28px 32px 36px; }
.viewer-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 14px;
  word-break: break-word;
}
.viewer-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  padding-bottom: 16px;
  margin-bottom: 22px;
  border-bottom: 1px dashed var(--border);
  font-size: 12.5px;
  color: var(--text-3);
}
.viewer-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.viewer-meta-item svg { width: 14px; height: 14px; opacity: .85; }
.viewer-meta-tags { display: inline-flex; gap: 6px; flex-wrap: wrap; }

.viewer-content { font-size: 15px; line-height: 1.85; color: var(--text); }
.viewer-content.ql-editor { padding: 0; }
.viewer-content img { max-width: 100%; height: auto; border-radius: 6px; margin: 12px 0; }
/* 多图栅格：桌面 5 列 / 移动 3 列 */
.viewer-content .img-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin: 14px 0;
}
.viewer-content .img-grid-item { margin: 0; padding: 0; }
.viewer-content .img-grid-item img {
  width: 100%;
  height: auto;
  margin: 0;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: var(--sh-1);
  cursor: zoom-in;
}
@media (max-width: 640px) {
  .viewer-content .img-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
}
.viewer-content p { margin: 0 0 12px; }
.viewer-content h1, .viewer-content h2, .viewer-content h3 { margin: 22px 0 12px; font-weight: 700; }
.viewer-content h1 { font-size: 22px; }
.viewer-content h2 { font-size: 19px; }
.viewer-content h3 { font-size: 16.5px; }
.viewer-content blockquote {
  margin: 14px 0; padding: 10px 16px;
  border-left: 4px solid var(--brand-light);
  background: var(--brand-soft);
  border-radius: 0 6px 6px 0;
  color: var(--text);
}
.viewer-content pre, .viewer-content code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}
.viewer-content pre {
  background: #1E293B;
  color: #E2E8F0;
  padding: 14px 16px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
}
.viewer-content code { background: rgba(99,102,241,.1); color: var(--brand-dark); padding: 1px 6px; border-radius: 4px; font-size: 13px; }
.viewer-content pre code { background: transparent; color: inherit; padding: 0; }
.viewer-content a { color: var(--brand); text-decoration: underline; }
.viewer-content ul, .viewer-content ol { padding-left: 24px; margin: 8px 0 14px; }

@media (max-width: 640px) {
  .viewer-article { padding: 20px 18px 28px; }
  .viewer-title { font-size: 21px; }
}

/* ============================================================
   图片灯箱
   ============================================================ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 23, .92);
  backdrop-filter: blur(4px);
}
.lightbox.hidden { display: none; }
.lightbox-img {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  user-select: none;
}
.lightbox-close {
  position: absolute;
  top: 18px; right: 18px;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: #fff; font-size: 20px;
  cursor: pointer;
  transition: background .15s;
}
.lightbox-close:hover { background: rgba(255, 255, 255, .25); }
.lightbox-close svg { width: 20px; height: 20px; }
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  color: #fff; font-size: 28px; line-height: 1;
  cursor: pointer;
  transition: background .15s;
}
.lightbox-nav:hover { background: rgba(255, 255, 255, .22); }
.lightbox-prev { left: 18px; }
.lightbox-next { right: 18px; }
.lightbox-counter {
  position: absolute;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, .75);
  font-size: 13px;
  background: rgba(0, 0, 0, .35);
  padding: 4px 12px;
  border-radius: 99px;
}

/* ============================================================
   文章列表（响应式双列）
   ============================================================ */
.article-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 768px) { .article-grid { grid-template-columns: repeat(2, 1fr); } }

/* ============================================================
   回收站统计条
   ============================================================ */
.recycle-stat-strip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px 18px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 12px;
  color: #991B1B;
  font-size: 13.5px;
}
.recycle-stat-strip b { color: #DC2626; font-size: 16px; margin: 0 2px; }
.recycle-stat-strip .rs-icon { font-size: 16px; }

/* AI 搜索按钮（桌面端搜索框内） */
.ai-search-btn {
  position: absolute;
  right: 44px; top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 24px;
  padding: 0 8px;
  border: none;
  border-radius: 99px;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .3px;
  cursor: pointer;
  transition: box-shadow .16s, transform .12s, opacity .16s;
}
.ai-search-btn svg { width: 11px; height: 11px; }
.ai-search-btn:hover {
  box-shadow: 0 2px 8px rgba(99, 102, 241, .45);
  transform: translateY(-50%) scale(1.04);
}
.ai-search-btn:active { transform: translateY(-50%) scale(.95); }
.ai-search-btn.is-disabled {
  background: #CBD5E1;
  cursor: not-allowed;
  opacity: .75;
}
.ai-search-btn.is-disabled:hover {
  box-shadow: none;
  transform: translateY(-50%);
}

/* AI 摘要卡片 */
.ai-summary-card {
  margin: 6px 4px 10px;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(99,102,241,.08), rgba(139,92,246,.08));
  border: 1px solid rgba(99, 102, 241, .22);
  border-radius: 12px;
}
.ai-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.ai-summary-badge {
  font-size: 12.5px;
  font-weight: 700;
  color: #6D28D9;
  background: rgba(139, 92, 246, .12);
  padding: 2px 9px;
  border-radius: 99px;
}
.ai-summary-model {
  font-size: 10px;
  color: var(--text-3);
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-summary-text {
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--text);
}

/* AI 加载动画 */
.ai-loading-card {
  padding: 26px 16px;
  text-align: center;
}
.ai-thinking {
  display: inline-flex;
  gap: 6px;
  margin-bottom: 12px;
}
.ai-thinking span {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--brand);
  animation: ai-bounce 1.2s infinite ease-in-out;
}
.ai-thinking span:nth-child(2) { animation-delay: .15s; }
.ai-thinking span:nth-child(3) { animation-delay: .3s; }
@keyframes ai-bounce {
  0%, 80%, 100% { transform: scale(.55); opacity: .35; }
  40% { transform: scale(1); opacity: 1; }
}
.ai-loading-title { font-size: 13.5px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.ai-loading-text { font-size: 12px; color: var(--text-3); line-height: 1.6; }

/* AI 匹配度徽章与理由 */
.ai-match {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: 600;
  margin-right: 6px;
  vertical-align: 1px;
}
.match-high { background: rgba(16, 185, 129, .13); color: #059669; }
.match-mid { background: rgba(245, 158, 11, .15); color: #D97706; }
.match-low { background: rgba(148, 163, 184, .18); color: #64748B; }
.si-reason { font-size: 11.5px; color: #7C3AED; margin-top: 3px; line-height: 1.5; }
.si-img-hit { margin-left: 6px; color: #D97706; }

.search-results {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(480px, 80vw);
  max-height: min(460px, 60vh);
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--sh-3);
  padding: 6px;
  z-index: 50;
}

.search-item {
  display: block;
  padding: 10px 12px;
  border-radius: var(--r-xs);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background .14s;
}
.search-item:hover, .search-item.is-active { background: var(--brand-soft); }
.search-item .si-title { font-weight: 600; font-size: 13.5px; color: var(--text); margin-bottom: 2px; }
.search-item .si-desc {
  font-size: 12px; color: var(--text-3);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.search-item .si-meta { font-size: 11px; color: var(--brand); margin-top: 4px; }
.search-empty { padding: 26px 12px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ============================================================
   移动端底部导航 / 搜索层
   ============================================================ */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  align-items: stretch;
  background: rgba(255,255,255,.94);
  backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--border);
  z-index: 45;
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-3);
  font-size: 10.5px;
  transition: color .16s;
}
.tab-item svg { width: 21px; height: 21px; }
.tab-item.active { color: var(--brand); font-weight: 600; }
.tab-item:active { background: #F8FAFC; }

.tab-fab {
  flex: 0 0 auto;
  width: 54px; height: 54px;
  margin: -20px 6px 0;
  border: 4px solid #fff;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, #8B5CF6 100%);
  color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 8px 22px rgba(79,70,229,.42);
  cursor: pointer;
  transition: transform .16s;
}
.tab-fab svg { width: 24px; height: 24px; }
.tab-fab:active { transform: scale(.92); }

.msearch {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 90;
  display: flex;
  flex-direction: column;
  animation: sheet-up .22s ease;
}
@keyframes sheet-up { from { opacity: 0; transform: translateY(12px); } }
.msearch-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top, 10px));
  border-bottom: 1px solid var(--border);
}
.msearch-input {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  background: #F1F5F9;
  border-radius: 99px;
  padding: 0 14px;
  height: 40px;
}
.msearch-input svg { width: 17px; height: 17px; color: var(--text-3); flex-shrink: 0; }
.msearch-input input {
  flex: 1;
  border: 0; outline: 0;
  background: transparent;
  font-size: 16px; /* 防止 iOS 自动放大 */
  padding: 0 50px 0 8px;
  min-width: 0;
}
.msearch-cancel {
  border: 0; background: none;
  color: var(--brand);
  font-size: 14px;
  padding: 8px 2px;
  cursor: pointer;
}
.msearch-results { flex: 1; overflow-y: auto; padding: 8px; }

/* 移动端搜索层内的 AI 按钮 */
.msearch-input .ai-search-btn {
  right: 8px;
  height: 26px;
  padding: 0 10px;
  font-size: 11.5px;
}
.msearch-input .ai-search-btn svg { width: 12px; height: 12px; }

/* ============================================================
   按钮
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s, box-shadow .16s, transform .12s, border-color .16s, color .16s;
  text-decoration: none;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, #6D5BEA 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79,70,229,.28);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 18px rgba(79,70,229,.38); filter: brightness(1.05); }

.btn-outline {
  background: #fff;
  border-color: var(--border-2);
  color: var(--text-2);
}
.btn-outline:hover:not(:disabled) { border-color: var(--brand-light); color: var(--brand); background: var(--brand-soft); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: #F1F5F9; color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; box-shadow: 0 2px 8px rgba(239,68,68,.25); }
.btn-danger:hover:not(:disabled) { filter: brightness(1.06); box-shadow: 0 6px 16px rgba(239,68,68,.32); }

.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: var(--r-xs); }
.btn-sm svg { width: 14px; height: 14px; }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .16s, color .16s;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: #F1F5F9; color: var(--text); }
.icon-btn:active { background: #E2E8F0; }
.icon-btn-light { color: #94A3B8; }
.icon-btn-light:hover { background: rgba(255,255,255,.1); color: #fff; }

/* 卡片内操作按钮 */
.act-btn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #F1F5F9;
  color: var(--text-2);
  cursor: pointer;
  transition: all .16s;
}
.act-btn svg { width: 15px; height: 15px; }
.act-btn:hover { background: #fff; border-color: var(--border-2); color: var(--brand); box-shadow: var(--sh-1); }
.act-btn.danger:hover { color: var(--danger); border-color: #FCA5A5; background: var(--danger-soft); }

.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  transition: opacity .18s, transform .18s;
}
@media (hover: hover) and (pointer: fine) {
  .card-actions { opacity: 0; transform: translateX(4px); }
  .hover-host:hover .card-actions,
  .card-actions:focus-within { opacity: 1; transform: none; }
}

/* ============================================================
   表单
   ============================================================ */
.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  background: #fff;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.form-textarea { resize: vertical; min-height: 84px; }
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-3); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--brand-light);
  box-shadow: 0 0 0 4px var(--brand-ring);
}

.form-select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 15px;
  cursor: pointer;
  /* 确保文字不被箭头图标覆盖 */
  -webkit-appearance: none;
  -moz-appearance: none;
  text-overflow: clip;
  overflow: visible;
}

.color-options { display: flex; flex-wrap: wrap; gap: 9px; }
.color-dot {
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  box-shadow: 0 0 0 1px rgba(15,23,42,.08);
  transition: transform .15s, box-shadow .15s;
}
.color-dot:hover { transform: scale(1.12); }
.color-dot.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2.5px var(--brand);
  transform: scale(1.1);
}

/* ============================================================
   页面通用元素
   ============================================================ */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--text);
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.page-sub { font-size: 13px; color: var(--text-3); margin: 0; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.panel-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.panel-title { font-size: 14.5px; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 8px; }
.panel-body { padding: 16px 18px; }

/* 统计卡片 */
.stat-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--sh-1);
  overflow: hidden;
  transition: transform .18s, box-shadow .18s;
}
.stat-card::before {
  content: '';
  position: absolute;
  right: -30px; top: -30px;
  width: 110px; height: 110px;
  border-radius: 50%;
  background: var(--brand-soft);
  opacity: .5;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--sh-2); }
.stat-icon {
  position: relative;
  width: 42px; height: 42px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 19px;
  margin-bottom: 12px;
}
.stat-value {
  position: relative;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.1;
  color: var(--text);
}
.stat-label { position: relative; font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

/* 文章卡片 */
.article-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--sh-1);
  cursor: pointer;
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.article-card:hover {
  transform: translateY(-2px);
  border-color: #D9DEEB;
  box-shadow: var(--sh-2);
}
.article-card:active { transform: scale(.995); }
.article-title {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 6px;
  line-height: 1.45;
}
.article-excerpt {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.article-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 12px;
  font-size: 11.5px;
  color: var(--text-3);
}
.article-meta .meta-item { display: inline-flex; align-items: center; gap: 4px; }
.article-meta svg { width: 13px; height: 13px; }

/* 标签 */
.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.7;
  white-space: nowrap;
}
.tag-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

.tag-select { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border-2);
  border-radius: 99px;
  background: #fff;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  transition: all .16s;
}
.tag-option:hover { border-color: var(--brand-light); color: var(--brand); }
.tag-option.selected {
  background: var(--brand-soft);
  border-color: var(--brand-light);
  color: var(--brand);
  font-weight: 600;
}

/* 筛选条 */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--sh-1);
  margin-bottom: 16px;
}
.filter-bar .form-input,
.filter-bar .form-select { height: 36px; min-height: 36px; font-size: 13px; }

.chip-scroller {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.chip-scroller::-webkit-scrollbar { display: none; }

/* 空状态 */
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-3);
}
.empty-state .empty-icon {
  font-size: 42px;
  margin-bottom: 12px;
  opacity: .75;
  line-height: 1;
}
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-2); margin: 0 0 6px; }
.empty-state p { font-size: 13px; margin: 0 auto 18px; max-width: 380px; }

/* 骨架屏 */
.skeleton {
  background: linear-gradient(90deg, #EEF1F6 25%, #F7F9FC 50%, #EEF1F6 75%);
  background-size: 200% 100%;
  animation: sk 1.3s ease-in-out infinite;
  border-radius: var(--r);
}
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* 数据条（统计看板） */
.bar-row { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 9px 0; }
.bar-row + .bar-row { border-top: 1px dashed var(--border); }
.bar-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
.bar-head .bar-name {
  font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bar-head .bar-val { color: var(--text-3); font-size: 12px; flex-shrink: 0; }
.bar-track { height: 8px; border-radius: 99px; background: #EEF2F7; overflow: hidden; }
.bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--brand-light), #8B5CF6);
  width: 0;
  transition: width .8s cubic-bezier(.22,1,.36,1);
}

.legend-list { display: grid; gap: 8px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.legend-item .lg-dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.legend-item .lg-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend-item .lg-val { color: var(--text-3); font-size: 12px; }

/* ============================================================
   模态框
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.42);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }

.modal-content {
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  overflow: hidden;
  animation: pop .22s cubic-bezier(.22,1,.36,1);
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } }

.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}
.modal-header h3 { margin: 0; font-size: 16px; font-weight: 700; color: var(--text); }
.modal-close {
  width: 32px; height: 32px;
  border: 0; border-radius: 8px;
  background: transparent;
  color: var(--text-3);
  font-size: 20px; line-height: 1;
  cursor: pointer;
  display: grid; place-items: center;
}
.modal-close:hover { background: #F1F5F9; color: var(--text); }

.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
  background: #FBFCFE;
}

/* ============================================================
   Toast
   ============================================================ */
.toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  max-width: min(400px, 90vw);
  padding: 12px 16px;
  border-radius: var(--r);
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--sh-3);
  font-size: 13.5px;
  color: var(--text);
  pointer-events: auto;
  animation: toast-in .26s cubic-bezier(.22,1,.36,1);
}
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } }
.toast.toast-out { animation: toast-out .22s ease forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }
.toast::before {
  content: '';
  width: 4px;
  align-self: stretch;
  border-radius: 99px;
  flex-shrink: 0;
}
.toast-success::before { background: var(--success); }
.toast-error::before   { background: var(--danger); }
.toast-info::before    { background: var(--brand); }
.toast-warning::before { background: var(--warn); }

/* ============================================================
   编辑器
   ============================================================ */
.editor-shell {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.editor-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
#editor-title {
  flex: 1;
  min-width: 180px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  font-family: inherit;
}
#editor-title::placeholder { color: #CBD5E1; font-weight: 600; }

.editor-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  background: #FBFCFE;
}
.editor-meta .form-select { height: 34px; min-height: 34px; font-size: 13px; width: auto; min-width: 130px; max-width: 100%; }

/* 编辑器下拉左侧装饰图标 */
#editor-kb, #editor-cat {
  padding-left: 30px !important;
  background-repeat: no-repeat, no-repeat !important;
  background-position: left 9px center, right 10px center !important;
  line-height: 1.4;
  background-size: 16px, 15px !important;
}
#editor-kb {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234F46E5' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M4 19.5A2.5 2.5 0 016.5 17H20M6.5 2H20v20H6.5A2.5 2.5 0 014 19.5v-15A2.5 2.5 0 016.5 2z'/%3E%3C/svg%3E"),
                    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") !important;
}
#editor-cat {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234F46E5' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z'/%3E%3C/svg%3E"),
                    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") !important;
}

/* ==================== 自定义下拉框（替换 native select） ==================== */
.custom-select {
  position: relative;
  flex: 0 0 auto;
  min-width: 130px;
  display: inline-block;
}

.custom-select-trigger {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: 34px;
  padding: 0 32px 0 32px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  background-color: #fff;
  background-repeat: no-repeat;
  background-position: left 9px center;
  background-size: 16px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color .16s, box-shadow .16s;
}
.custom-select-trigger:focus,
.custom-select-trigger:hover {
  border-color: var(--brand-light);
  box-shadow: 0 0 0 4px var(--brand-ring);
  outline: none;
}
.custom-select-trigger .cs-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  line-height: 32px;
}
.custom-select-trigger .cs-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-3);
  flex-shrink: 0;
  transition: transform .18s;
  pointer-events: none;
}
.custom-select.open .custom-select-trigger .cs-arrow {
  transform: translateY(-50%) rotate(180deg);
}

/* 不同下拉框的左侧图标（仅左侧装饰，右侧箭头由 HTML SVG 提供） */
.custom-select[data-icon="kb"] .custom-select-trigger {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234F46E5' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M4 19.5A2.5 2.5 0 016.5 17H20M6.5 2H20v20H6.5A2.5 2.5 0 014 19.5v-15A2.5 2.5 0 016.5 2z'/%3E%3C/svg%3E");
}
.custom-select[data-icon="cat"] .custom-select-trigger {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234F46E5' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z'/%3E%3C/svg%3E");
}

.custom-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--sh-3);
  padding: 5px;
  z-index: 50;
  -webkit-overflow-scrolling: touch;
  animation: fade-up .18s ease;
}

.custom-select-option {
  padding: 8px 12px;
  border-radius: var(--r-xs);
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .14s, color .14s;
}
.custom-select-option:hover {
  background: var(--brand-soft);
  color: var(--brand);
}
.custom-select-option.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}

/* 移动端下拉框适配 */
@media (max-width: 767px) {
  .editor-meta .custom-select { min-width: 130px; max-width: 60vw; }
  .editor-meta .custom-select-trigger {
    height: 42px;
    font-size: 15px;
    padding: 0 28px 0 30px;
    background-size: 16px, 15px;
  }
  .editor-meta .custom-select-trigger .cs-text {
    line-height: 40px;
  }

  /* 筛选下拉（无左侧图标） */
  .filter-custom-select .custom-select-trigger {
    height: 36px;
    font-size: 14px;
    padding: 0 28px 0 12px;
  }
  .filter-custom-select .custom-select-trigger .cs-text {
    line-height: 34px;
  }
}

/* 筛选下拉桌面端样式 */
.filter-custom-select .custom-select-trigger {
  padding: 0 28px 0 12px;
}
.filter-custom-select .custom-select-trigger .cs-text {
  line-height: 32px;
}

.upload-status {
  font-size: 12px;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 3px 10px;
  border-radius: 99px;
}
.upload-status:empty { display: none; }

.ql-toolbar.ql-snow {
  border: 0 !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 8px 12px !important;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 5;
}
.ql-container.ql-snow { border: 0 !important; font-family: inherit; font-size: 15px; }
.ql-editor {
  min-height: 46vh;
  padding: 20px 22px 60px;
  line-height: 1.85;
  color: #1E293B;
}
.ql-editor.ql-blank::before { color: #CBD5E1; font-style: normal; left: 22px; }
.ql-editor img { max-width: 220px; height: auto; border-radius: 8px; margin: 8px 10px 8px 0; vertical-align: middle; }
@media (max-width: 640px) { .ql-editor img { max-width: 140px; } }
.ql-editor h1 { font-size: 1.6em; }
.ql-editor h2 { font-size: 1.35em; }
.ql-editor h3 { font-size: 1.15em; }
.ql-editor blockquote {
  border-left: 3px solid var(--brand-light);
  background: #F8FAFF;
  padding: 6px 14px;
  border-radius: 0 8px 8px 0;
  color: var(--text-2);
}
.ql-editor pre.ql-syntax { background: #0F172A; border-radius: 10px; padding: 14px; }
.ql-snow .ql-stroke { stroke: #64748B; }
.ql-snow .ql-fill { fill: #64748B; }
.ql-snow .ql-picker { color: #64748B; }
.ql-snow button:hover .ql-stroke,
.ql-snow button.ql-active .ql-stroke { stroke: var(--brand) !important; }
.ql-snow button:hover .ql-fill,
.ql-snow button.ql-active .ql-fill { fill: var(--brand) !important; }
.ql-snow button { border-radius: 6px; }
.ql-snow button:hover { background: var(--brand-soft); }

/* 文章正文渲染 */
.prose-content { font-size: 15px; line-height: 1.85; color: #1E293B; }
.prose-content img { max-width: 100%; border-radius: 10px; }
.prose-content a { color: var(--brand); text-decoration: underline; }

/* ============================================================
   动画
   ============================================================ */
.fade-in { animation: fade-up .28s cubic-bezier(.22,1,.36,1) both; }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

/* ============================================================
   响应式：默认桌面，向下适配
   ============================================================ */
.mobile-only { display: none !important; }

/* ---------- 平板 ---------- */
@media (max-width: 1080px) {
  .search-box { width: 240px; }
  .search-kbd { display: none; }
  .app-content { padding-left: 22px; padding-right: 22px; }
  .topbar { padding-left: 16px; padding-right: 16px; }
}

/* ---------- 侧边栏抽屉化 ---------- */
@media (max-width: 1023px) {
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: min(84vw, 300px);
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.22,1,.36,1);
    box-shadow: var(--sh-3);
  }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
}

/* ---------- 手机 ---------- */
@media (max-width: 767px) {
  .mobile-only { display: flex !important; }
  .desktop-only { display: none !important; }
  button.mobile-only { display: grid !important; }

  :root { --topbar-h: 56px; }

  .app-content {
    padding: 16px 14px calc(var(--tabbar-h) + var(--safe-b) + 28px);
  }
  .topbar { padding: 0 8px 0 6px; gap: 4px; }

  .breadcrumb { font-size: 12.5px; }
  .breadcrumb .crumb-current { font-size: 16px; }
  /* 移动端仅保留最后一级标题，节省空间 */
  .breadcrumb > *:not(:last-child) { display: none; }

  .page-title { font-size: 19px; }
  .page-head { margin-bottom: 14px; gap: 10px; }

  /* 触控友好：最小点击尺寸 */
  .btn { height: 42px; padding: 0 16px; font-size: 14px; border-radius: var(--r-sm); }
  .btn-sm { height: 36px; font-size: 13px; }
  .icon-btn { width: 40px; height: 40px; }
  .act-btn { width: 36px; height: 36px; }
  .act-btn svg { width: 17px; height: 17px; }
  .tag-option { padding: 8px 14px; font-size: 13px; }

  /* 输入框 16px 防止 iOS 聚焦时页面缩放 */
  .form-input, .form-select, .form-textarea, #editor-title { font-size: 16px; }
  .form-input, .form-select { min-height: 44px; }
  /* 修复移动端 select 文字被右侧箭头截断 */
  .form-select {
    min-width: 0;
    width: auto;
    padding-right: 30px;
    max-width: 100%;
    text-overflow: clip;
    overflow: visible;
  }

  /* 卡片 */
  .stat-card { padding: 14px; border-radius: var(--r); }
  .stat-icon { width: 36px; height: 36px; font-size: 17px; margin-bottom: 8px; border-radius: 10px; }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 11.5px; }
  .article-card { padding: 14px; border-radius: var(--r); }
  .article-card:hover { transform: none; box-shadow: var(--sh-1); }
  .article-title { font-size: 15px; }
  .panel { border-radius: var(--r); }
  .panel-head { padding: 13px 14px; }
  .panel-body { padding: 13px 14px; }

  .filter-bar {
    padding: 10px 12px;
    gap: 8px;
    border-radius: var(--r);
  }
  .filter-bar { flex-wrap: nowrap; overflow-x: auto; gap: 6px; }
  .filter-bar .form-select { flex: 0 0 auto; min-width: 120px; max-width: 45vw !important; }
  .filter-bar .form-input { flex: 1 1 80px; min-width: 60px; }
  .filter-bar .btn { flex-shrink: 0; }

  /* 底部弹出式模态框 */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-content {
    max-width: 100%;
    max-height: 92dvh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    animation: sheet-in .28s cubic-bezier(.22,1,.36,1);
    padding-bottom: var(--safe-b);
  }
  @keyframes sheet-in { from { transform: translateY(100%); } }
  .modal-header { padding: 16px 18px 12px; position: relative; }
  .modal-header::before {
    content: '';
    position: absolute;
    top: 7px; left: 50%;
    transform: translateX(-50%);
    width: 38px; height: 4px;
    border-radius: 99px;
    background: #E2E8F0;
  }
  .modal-body { padding: 16px 18px; }
  .modal-footer { padding: 12px 18px; }
  .modal-footer .btn { flex: 1; }

  /* Toast 顶部居中 */
  .toast-container { top: max(12px, env(safe-area-inset-top, 12px)); left: 12px; right: 12px; align-items: center; }
  .toast { width: 100%; animation: toast-drop .26s cubic-bezier(.22,1,.36,1); }
  @keyframes toast-drop { from { opacity: 0; transform: translateY(-16px); } }
  .toast.toast-out { animation: toast-up .2s ease forwards; }
  @keyframes toast-up { to { opacity: 0; transform: translateY(-16px); } }

  /* 编辑器 */
  .editor-shell { border-radius: var(--r); }
  .editor-topbar { padding: 12px 14px; }
  .editor-meta { padding: 10px 14px; gap: 8px; }
  .editor-meta { gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 10px 14px; }
  .editor-meta::-webkit-scrollbar { display: none; }
  .editor-meta .form-select {
    flex: 0 0 auto;
    min-width: 130px;
    max-width: 60vw;
    padding: 12px 28px 8px 30px !important;
    height: 42px !important;
    min-height: 42px !important;
    font-size: 15px !important;
    line-height: 1.2 !important;
  }
  #editor-kb, #editor-cat { min-width: 130px !important; }
  .ql-toolbar.ql-snow {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 6px 8px !important;
    gap: 2px;
  }
  .ql-toolbar.ql-snow::-webkit-scrollbar { display: none; }
  .ql-toolbar.ql-snow .ql-formats { margin-right: 8px !important; white-space: nowrap; flex-shrink: 0; }
  .ql-editor { min-height: 44vh; padding: 16px 14px 40px; font-size: 16px; }
  .ql-editor.ql-blank::before { left: 14px; }

  /* 移动端固定底部保存条 */
  .editor-actionbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    display: flex;
    gap: 10px;
    padding: 10px 14px calc(10px + var(--safe-b));
    background: rgba(255,255,255,.96);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    z-index: 46;
  }
  .editor-actionbar .btn { flex: 1; }
  body.editing .tabbar { display: none !important; }
  body.editing .app-content { padding-bottom: calc(70px + var(--safe-b)); }

  .empty-state { padding: 44px 16px; }
}

/* ---------- 超小屏 ---------- */
@media (max-width: 360px) {
  .tab-item span { font-size: 9.5px; }
  .stat-value { font-size: 20px; }
}

/* ---------- 横屏手机 ---------- */
@media (max-height: 480px) and (orientation: landscape) {
  .ql-editor { min-height: 40vh; }
  .modal-content { max-height: 96dvh; }
}
