@import url("/css/design-tokens.css?v=a2");

/* Xiaoyu shared components; legacy layout retained, theme unified. */

/* Shared brand, typography and component surfaces. */
html { color-scheme: light; }
body { background: var(--bg-main); color: var(--text-primary); }
body :is(button,a,input,textarea,select,[contenteditable]):focus-visible { outline: 3px solid var(--brand-primary); outline-offset: 3px; }
:is(input,textarea,select,label,.app,.form-card,.wb-editor,.reading-main,.table-wrap) { min-width: 0; }
.xy-companion-strip { width: min(100%,1100px); margin: 26px auto 0; padding: 0 5vw; display: flex; align-items: center; gap: 13px; color: var(--text-secondary); }
.xy-companion-strip strong { font-size: .93rem; color: var(--text-primary); font-weight: 600; }
.xy-companion-strip p { font-size: .78rem; margin-top: 2px; }
.xy-companion-strip a { margin-left: auto; white-space: nowrap; color: var(--brand-primary); text-decoration: none; font-size: .78rem; }
.xiaoyu-home .xy-companion-strip { display: none; }
.xy-avatar { display: inline-block; position: relative; overflow: hidden; width: 48px; height: 48px; border-radius: 50%; flex: 0 0 48px; background: var(--bg-soft); border: 1px solid var(--border-soft); }
.xy-avatar img { position: absolute; width: 155%; height: auto; max-width: none; left: -28%; top: -5%; }
.empty-state .xy-avatar { margin: 0 auto 14px; }
.xy-empty-note { display: block; color: var(--brand-primary); font-size: .78rem; margin-top: 16px; }
.xy-login-welcome { display: flex; align-items: center; gap: 13px; color: var(--brand-primary); font-size: .9rem; }
.xy-article-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }



* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.7;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Legacy grid and starfield retired globally. */
#bg, body::before { display: none; }

/* ---------- 头部 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 5vw;
  background: var(--bg-main);
  backdrop-filter: none;
  border-bottom: 1px solid var(--border-soft);
  transition: border-color .4s ease, background .4s ease;
}

.site-header.scrolled {
  background: var(--bg-card);
  border-bottom-color: var(--border-soft);
}

.logo {
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -0.04em;
  font-family: var(--font-sans);
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
}

.logo .accent { color: var(--brand-primary); }

.main-nav { display: flex; gap: 20px; align-items: center; }

.nav-link {
  position: relative;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color .3s ease;
  padding: 4px 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 0; bottom: -2px;
  width: 100%; height: 2px;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .35s ease;
  border-radius: 2px;
}

.nav-link:hover, .nav-link.active { color: var(--text-primary); }
.nav-link:hover::after, .nav-link.active::after { transform: scaleX(1); }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border-soft);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 10px 15px;
  min-width: 44px;
  min-height: 44px;
  font-size: 1.1rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ---------- 主内容 ---------- */
.app {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 5vw 60px;
}

/* ---------- Hero ---------- */
.hero {
  min-height: 62vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 0;
}

.hero-title {
  font-size: clamp(2.2rem, 6vw, 4.2rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.gradient {
  background: linear-gradient(120deg, var(--brand-primary), var(--brand-accent) 55%, var(--brand-accent));
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: gradientFlow 6s ease infinite;
}

.hero-sub {
  margin-top: 22px;
  max-width: 560px;
  color: var(--text-secondary);
  font-size: 1.05rem;
}

.hero-sub b { color: var(--brand-primary); font-weight: 600; }

.hero-cta { margin-top: 34px; display: flex; gap: 16px; flex-wrap: wrap; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 26px;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
  transition: transform .25s ease, box-shadow .25s ease, background .25s ease, border-color .25s ease;
}

.btn-primary {
  background: var(--brand-primary);
  color: #fff;
  box-shadow: var(--shadow-soft);
}

.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }

.btn-ghost {
  border-color: var(--border-soft);
  color: var(--text-primary);
  background: transparent;
}

.btn-ghost:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-soft);
  transform: translateY(-2px);
}

.btn-block { width: 100%; text-align: center; border: none; }

.btn-danger { background: transparent; border-color: var(--border-strong); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; }

.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* ---------- 区块标题 ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.section-title {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 650;
}

.section-en {
  font-family: var(--font-mono);
  font-size: 0.72em;
  color: var(--text-secondary);
  letter-spacing: 0.1em;
  margin-left: 10px;
}

/* ---------- 搜索框 ---------- */
.search-bar { display: flex; gap: 10px; flex: 1; min-width: 220px; max-width: 420px; }

.search-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  color: var(--text-primary);
  padding: 9px 18px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color .3s ease, box-shadow .3s ease;
}

.search-input:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--bg-soft);
}

/* ---------- 文章卡片 ---------- */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 22px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  overflow: hidden;
  backdrop-filter: none;
  transition: transform .35s cubic-bezier(.22,.68,.36,1), box-shadow .35s ease, border-color .35s ease, opacity .3s;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-hover);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.4;
  background: none;
  -webkit-background-clip: text;
  background-clip: text;
  color: var(--text-primary);
}

.card-excerpt {
  color: var(--text-secondary);
  font-size: 0.92rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.card-meta .views { white-space: nowrap; }

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

.tag {
  font-size: 0.7rem;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  color: var(--brand-primary);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  transition: border-color .2s, color .2s;
}

.tag:hover { border-color: var(--border-strong); color: var(--text-primary); }

.badge {
  display: inline-block;
  font-size: 0.68rem;
  padding: 1px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
}

.badge-draft { background: var(--warning-soft); border: 1px solid var(--warning-soft); color: var(--warning); }
.badge-published { background: var(--success-soft); border: 1px solid var(--success-soft); color: var(--success); }
.badge-scheduled { background: var(--bg-soft); border: 1px solid var(--border-strong); color: var(--brand-primary); }

.category-chip {
  font-size: 0.74rem;
  color: var(--brand-accent);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 2px 10px;
  text-decoration: none;
  font-family: var(--font-mono);
}

/* ---------- 加载骨架 ---------- */
.skeleton {
  height: 180px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-soft) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

.skeleton-line {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--bg-soft) 25%, var(--bg-soft) 50%, var(--bg-soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

/* ---------- 空 / 错误状态 ---------- */
.empty-state {
  text-align: center;
  padding: 70px 20px;
  color: var(--text-secondary);
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius);
  background: var(--bg-card);
}

.empty-state .icon { font-size: 2.4rem; margin-bottom: 12px; opacity: 0.7; }
.empty-state h3 { color: var(--text-primary); margin-bottom: 6px; font-size: 1.15rem; }
.empty-state p { font-size: 0.9rem; }

.error-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--danger);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--danger-soft);
}

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 36px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  cursor: pointer;
  font-size: 0.88rem;
  transition: all .25s;
}

.page-btn:hover:not(:disabled) { border-color: var(--border-strong); color: var(--text-primary); }
.page-btn.active { background: var(--brand-primary); color: #fff; border-color: transparent; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.page-info { color: var(--text-secondary); font-size: 0.82rem; font-family: var(--font-mono); }

/* ---------- 文章正文 ---------- */
.post-page { max-width: 780px; margin: 0 auto; }

.post-header { margin-bottom: 30px; }

.post-title {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  font-weight: 800;
  line-height: 1.3;
  background: none;
  -webkit-background-clip: text;
  background-clip: text;
  color: var(--text-primary);
  margin-bottom: 14px;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: var(--font-mono);
  margin-bottom: 16px;
}

.post-cat { color: var(--brand-accent); text-decoration: none; border: 1px solid var(--border-strong); padding: 1px 10px; border-radius: 999px; font-size: 0.78rem; }
.post-cat:hover { border-color: var(--brand-accent); }

.post-divider { border: none; border-top: 1px solid var(--border-soft); margin-bottom: 30px; }

.article { font-size: 1rem; line-height: 1.85; overflow-wrap: break-word; }

.article h1, .article h2, .article h3, .article h4 {
  margin: 26px 0 12px;
  line-height: 1.35;
  font-weight: 700;
  overflow-wrap: break-word;
}
.article h1 { font-size: 1.6rem; color: var(--text-primary); }
.article h2 { font-size: 1.35rem; color: var(--brand-primary); padding-bottom: 8px; border-bottom: 1px solid var(--border-soft); }
.article h3 { font-size: 1.15rem; }
.article p { margin: 14px 0; }
.article a { color: var(--brand-primary); text-decoration: underline; text-underline-offset: 3px; word-break: break-all; }
.article a:hover { color: var(--text-primary); }
.article ul, .article ol { margin: 14px 0; padding-left: 24px; }
.article li { margin: 6px 0; }
.article li::marker { color: var(--brand-accent); }
.article strong { color: var(--text-primary); font-weight: 700; }
.article em { color: var(--text-primary); }
.article blockquote {
  border-left: 3px solid var(--brand-accent);
  background: var(--bg-soft);
  padding: 12px 18px;
  color: var(--text-secondary);
  margin: 16px 0;
  border-radius: 0 10px 10px 0;
}
.article blockquote p { margin: 6px 0; }
.article code {
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 1px 7px;
  font-family: var(--font-mono);
  font-size: 0.86em;
  color: var(--brand-primary);
}
.article pre {
  background: var(--code-bg);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 16px 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  max-width: 100%;
  margin: 16px 0;
  line-height: 1.6;
}
.article pre code { background: none; border: none; padding: 0; color: #d7e2f2; font-size: 0.85rem; white-space: pre; overflow-wrap: normal; word-break: normal; }
.article img { max-width: 100%; height: auto; display: block; border-radius: 10px; border: 1px solid var(--border-soft); }
.article hr { border: none; border-top: 1px solid var(--border-soft); margin: 24px 0; }
.article table { border-collapse: collapse; width: 100%; margin: 16px 0; font-size: 0.92rem; }
.article th, .article td { border: 1px solid var(--border-soft); padding: 8px 12px; text-align: left; }
.article th { background: var(--bg-soft); color: var(--brand-primary); }
.article input[type="checkbox"] { accent-color: var(--brand-primary); margin-right: 6px; }

/* ---------- V1.6-A：阅读体验（进度条 / TOC / 相邻导航 / 相关推荐 / 灯箱） ---------- */
.reading-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 250;
  pointer-events: none;
  background: transparent;
}
.reading-progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
  transition: width .12s ease-out;
}

.reading-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 28px;
  align-items: start;
}
.post-toc {
  position: sticky;
  top: 90px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding: 12px 10px;
  border-left: 1px solid var(--border-soft);
  font-size: 0.82rem;
}
.post-toc-hidden { display: none; }
.post-toc .toc-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
}
.toc-list { list-style: none; margin: 0; padding: 0; }
.toc-item { margin: 4px 0; }
.toc-item a {
  color: var(--text-secondary);
  text-decoration: none;
  display: block;
  padding: 2px 6px;
  border-radius: 6px;
  transition: color .2s, background .2s;
  word-break: break-word;
}
.toc-item a:hover { color: var(--text-primary); }
.toc-item.toc-active a { color: var(--brand-primary); background: var(--bg-soft); }
.toc-l2 { padding-left: 10px; }
.toc-l3 { padding-left: 20px; }

.reading-main { min-width: 0; }

.post-adjacent {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 32px;
}
.adjacent-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  color: var(--text-primary);
  text-decoration: none;
  background: var(--bg-card);
  transition: border-color .2s, transform .2s;
}
.adjacent-link:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.adjacent-label { color: var(--text-secondary); font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.06em; }
.adjacent-title { font-weight: 600; word-break: break-word; }
.adjacent-next { text-align: right; }
.adjacent-empty { visibility: hidden; }

.related-posts { margin-top: 32px; }
.related-posts .section-title { margin-bottom: 14px; }
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.related-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  color: var(--text-primary);
  text-decoration: none;
  background: var(--bg-card);
  transition: border-color .2s, transform .2s;
}
.related-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.related-cover {
  display: block;
  width: 100%;
  margin-bottom: 6px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-card);
}
.related-cover img { display: block; width: 100%; height: 110px; object-fit: cover; }
.related-title { font-weight: 600; font-size: 0.92rem; line-height: 1.35; word-break: break-word; }
.related-cat { color: var(--brand-accent); font-size: 0.75rem; font-family: var(--font-mono); }

/* 图片灯箱 */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: var(--overlay);
  backdrop-filter: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}
.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  cursor: default;
}
.lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-close:hover { border-color: var(--border-strong); color: var(--danger); }
.article img.lightboxable { cursor: zoom-in; }

.post-footer {
  margin-top: 44px;
  padding-top: 22px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.post-tags { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.post-tags .label { color: var(--text-secondary); font-size: 0.82rem; font-family: var(--font-mono); }

/* ---------- 分类 / 标签云 ---------- */
.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.92rem;
  transition: all .25s;
}

.chip:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: 0 8px 24px var(--bg-soft); }

.chip .count { color: var(--text-secondary); font-size: 0.78rem; font-family: var(--font-mono); }

/* ---------- 表单 ---------- */
.form-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 28px;
  backdrop-filter: none;
}

.form-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.form-card input[type="text"],
.form-card input[type="password"],
.form-card input[type="search"],
.form-card textarea,
.form-card select {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  color: var(--text-primary);
  padding: 12px 15px;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color .3s ease, box-shadow .3s ease;
  width: 100%;
}

.form-card textarea { resize: vertical; line-height: 1.6; }
.form-card select option { background: var(--bg-card); }

.form-card input:focus, .form-card textarea:focus, .form-card select:focus {
  border-color: var(--brand-primary);
  box-shadow: var(--focus-ring);
}

.field-hint { font-size: 0.78rem; color: var(--text-secondary); }

/* ---------- V1.5-A：后台文章管理（筛选/编辑器体验） ---------- */
.admin-filters { }
.admin-filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.admin-filter-row .search-input { min-width: 160px; }
.adm-select {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  color: var(--text-primary);
  padding: 9px 12px;
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}
.adm-select:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 3px var(--bg-soft); }
.adm-select option { background: var(--bg-card); }

/* 编辑器信息面板 */
.editor-card { max-width: 1100px; }
.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.editor-status-line { display: flex; align-items: center; gap: 10px; }
.editor-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
}
.editor-dirty { color: var(--warning) !important; }

/* ---------- V1.8-D：管理员 AI 写作工作台 ---------- */
.ai-writing-panel {
  margin: 24px 0;
  padding: 18px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--bg-soft);
  box-shadow: 0 12px 32px var(--bg-soft);
}
.ai-writing-head,
.ai-result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.ai-writing-head h4,
.ai-result-head h4 {
  margin: 0 0 5px;
  font-size: 1.05rem;
  color: var(--text-primary);
}
.ai-writing-head p { margin: 0; }
.ai-writing-panel > label,
.ai-result > label { display: block; margin-bottom: 12px; }
.ai-writing-panel textarea,
.ai-result textarea { width: 100%; }
.ai-writing-panel #ai-topic { min-height: 94px; }
.ai-writing-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.ai-writing-options label { min-width: 0; }
.ai-writing-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.ai-writing-actions button:disabled { opacity: 0.55; cursor: not-allowed; }
.ai-writing-status { flex: 1 1 260px; min-width: 0; }
.ai-status-error { color: var(--warning) !important; }
.ai-result {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}
.ai-result-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}
.ai-result-pane { min-width: 0; display: flex; flex-direction: column; }
.ai-result-pane textarea { min-height: 360px; font-family: var(--font-mono); line-height: 1.65; }
.ai-result-pane .md-preview { min-height: 360px; max-height: 520px; }

/* Markdown 编辑/预览分栏（桌面两栏，移动堆叠） */
.md-editor-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 8px;
}
.md-editor-pane {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.md-pane-head {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.md-editor-pane textarea {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  line-height: 1.65;
  min-height: 420px;
  resize: vertical;
}
.md-preview {
  min-height: 420px;
  padding: 14px 16px;
  overflow-y: auto;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--bg-card);
}
.editor-meta-line { display: flex; align-items: center; gap: 10px; min-height: 1.6em; }

/* ---------- V1.5-B2：Markdown 工具栏 + 独立预览 overlay ---------- */
.md-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
  padding: 6px 8px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--bg-soft);
}
.md-toolbar button {
  background: none;
  border: 1px solid transparent;
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 3px 8px;
  min-height: 28px;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  cursor: pointer;
  line-height: 1.2;
  transition: color .2s, border-color .2s, background .2s;
}
.md-toolbar button:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--bg-soft);
}
.md-toolbar .md-tb-sep {
  width: 1px;
  align-self: stretch;
  background: var(--border-soft);
  margin: 0 2px;
}

/* 全屏预览 overlay */
.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--overlay);
  backdrop-filter: none;
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px 80px;
}
.preview-overlay .preview-box {
  width: 100%;
  max-width: 780px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 24px;
}
.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.preview-head .preview-badges {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.preview-title {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 14px;
  word-break: break-word;
}
.preview-cover {
  display: block;
  width: 100%;
  margin-bottom: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  overflow: hidden;
  background: var(--bg-card);
}
.preview-cover img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  object-position: center;
}
.preview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  margin-bottom: 16px;
}
.preview-divider {
  border: none;
  border-top: 1px solid var(--border-soft);
  margin: 20px 0;
}
.preview-overlay .article { font-size: 1rem; line-height: 1.85; }

@media (max-width: 640px) {
  .preview-overlay { padding: 16px 10px 60px; }
  .md-toolbar { gap: 2px; }
  .md-toolbar button { padding: 4px 7px; min-height: 32px; }
}

@media (max-width: 840px) {
  .md-editor-layout { grid-template-columns: 1fr; }
  .md-editor-pane textarea,
  .md-preview { min-height: 260px; }
  .ai-result-layout { grid-template-columns: 1fr; }
  .ai-result-pane textarea,
  .ai-result-pane .md-preview { min-height: 260px; }
  .admin-filter-row { flex-direction: column; align-items: stretch; }
}

@media (max-width: 560px) {
  .ai-writing-panel { padding: 13px; margin: 18px 0; }
  .ai-writing-options { grid-template-columns: 1fr; gap: 8px; }
  .ai-writing-actions { align-items: stretch; }
  .ai-writing-actions button { width: 100%; }
  .ai-writing-status { flex-basis: 100%; }
}

/* ---------- V1.5-B1：批量管理工具栏 ---------- */
.batch-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.batch-select-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--text-primary);
  cursor: pointer;
}
.batch-select-all input { accent-color: var(--brand-primary); }
.batch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.batch-select-category, .batch-select-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.batch-select-tags select[multiple] {
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  color: var(--text-primary);
  padding: 8px;
}
.batch-select-tags select[multiple] option { background: var(--bg-card); }
.batch-row-check { accent-color: var(--brand-primary); }

@media (max-width: 640px) {
  .batch-toolbar-row { align-items: stretch; }
  .batch-actions { justify-content: flex-start; }
}

/* ---------- 封面图（后台预览 + 卡片/详情共用） ---------- */
.cover-preview-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

.cover-preview {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  box-shadow: 0 8px 24px var(--bg-soft);
}

.card-cover {
  display: block;
  width: 100%;
  margin: 0 0 14px;
  border-radius: calc(var(--radius) - 4px);
  border: 1px solid var(--border-soft);
  overflow: hidden;
  background: var(--bg-card);
}

.card-cover img {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: cover;
  object-position: center;
}

.card-cover img[onerror],
.card-cover img.error,
.post-cover img.error,
.card-cover img.broken,
.post-cover img.broken {
  display: none;
}

.post-cover {
  display: block;
  width: 100%;
  margin: 0 0 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  overflow: hidden;
  background: var(--bg-card);
}

.post-cover img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  object-position: center;
}

.form-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--bg-card); }

.admin-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 640px; }

.admin-table th {
  text-align: left;
  padding: 12px 16px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
  background: var(--bg-soft);
}

.admin-table td { padding: 12px 16px; border-bottom: 1px solid var(--bg-soft); vertical-align: middle; }

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

.admin-table tr:hover td { background: var(--bg-soft); }

.admin-table .cell-title { font-weight: 600; color: var(--text-primary); }
.admin-table .cell-mono { font-family: var(--font-mono); font-size: 0.82rem; color: var(--text-secondary); }
.admin-table .cell-actions { display: flex; gap: 8px; white-space: nowrap; }

/* ---------- 面板卡片 ---------- */
.panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 28px; }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: none;
}

.stat-card .num { font-size: 1.9rem; font-weight: 800; font-family: var(--font-mono); background: none; -webkit-background-clip: text; background-clip: text; color: var(--text-primary); }

.stat-card .label { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }

/* ---------- 页面加载指示 ---------- */
.page-loading {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 90;
  text-align: center;
  padding: 8px;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--brand-primary);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-soft);
  backdrop-filter: blur(8px);
}

.page-loading::before {
  content: "";
  display: inline-block;
  width: 11px; height: 11px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: -1px;
  animation: spin 0.8s linear infinite;
}

.hidden { display: none !important; }

/* ---------- 页面切换动画 ---------- */
.fade-page { animation: pageIn .3s ease; }

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

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px 22px;
  font-size: 0.9rem;
  box-shadow: 0 0 40px var(--bg-soft);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s, transform .3s;
  max-width: 90vw;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--border-strong); color: var(--danger); }

/* ---------- 页脚 ---------- */
.site-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 36px 5vw;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: var(--font-mono);
  border-top: 1px solid var(--border-soft);
  letter-spacing: 0.06em;
}

/* ---------- 动画 ---------- */
@keyframes gradientFlow {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes shimmer {
  to { background-position: -200% 0; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-main); }
::-webkit-scrollbar-thumb { background: linear-gradient(var(--brand-primary), var(--brand-accent)); border-radius: 6px; }

/* ---------- 语法高亮 ---------- */
.hljs { background: transparent; color: #d7e2f2; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-doctag { color: #c792ea; }
.hljs-number, .hljs-meta { color: #f78c6c; }
.hljs-string, .hljs-regexp, .hljs-addition { color: #a5e075; }
.hljs-title, .hljs-title.function_, .hljs-function .hljs-title { color: #82aaff; }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-type { color: #ffcb6b; }
.hljs-comment, .hljs-quote, .hljs-deletion { color: #637777; font-style: italic; }
.hljs-built_in, .hljs-symbol, .hljs-bullet { color: #ff9d00; }
.hljs-section, .hljs-title.class_, .hljs-class .hljs-title { color: #ffd700; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .site-header { padding: 12px 5vw; flex-wrap: wrap; }
  .main-nav {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 6px;
    padding: 12px 0 4px;
    border-top: 1px solid var(--border-soft);
  }
  .main-nav.open { display: flex; }
  .main-nav.open .nav-link {
    padding: 12px 6px;
    font-size: 1.02rem;
  }
  .nav-toggle { display: block; }
  .app { padding: 26px 5vw 44px; }
  .post-grid { grid-template-columns: 1fr; }
  .section-head { flex-direction: column; align-items: stretch; }
  .search-bar { max-width: none; }
  .hero { min-height: auto; padding: 30px 0; }
  .form-card { padding: 20px; }
  .pagination { gap: 6px; }
  .page-btn { min-width: 32px; height: 32px; }

  /* 移动端阅读体验 */
  .article { font-size: 0.97rem; }
  .article h1 { font-size: 1.4rem; }
  .article h2 { padding-bottom: 6px; font-size: 1.18rem; }
  .article h3 { font-size: 1.04rem; }
  .article pre { padding: 14px; margin: 14px 0; }
  .article blockquote { padding: 10px 14px; }

  /* 移动端封面 */
  .card-cover img { height: 150px; }
  .post-cover img { max-height: 240px; }

  /* V1.6-A 移动端阅读体验 */
  .reading-layout { grid-template-columns: 1fr; gap: 16px; }
  .post-toc {
    position: static;
    max-height: none;
    border-left: none;
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    background: var(--bg-card);
  }
  .post-adjacent { grid-template-columns: 1fr; }
  .related-grid { grid-template-columns: 1fr; }
  .lightbox-overlay { padding: 12px; }

  /* 移动端空 / 错误状态 */
  .empty-state { padding: 48px 16px; }
  .error-state { padding: 32px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}
/* ======================= 第二阶段：AI 文档工作台 ======================= */
.wb-editor { display: flex; flex-direction: column; gap: 12px; }
.wb-topbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wb-title-input-wrap { flex: 1 1 200px; min-width: 0; }
.wb-title-input-wrap input { width: 100%; font-size: 1.15rem; font-weight: 600; padding: 10px 12px; background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: 10px; color: var(--text-primary); }
.wb-status { display: inline-flex; align-items: center; gap: 8px; }

.wb-ai-panel { background: var(--bg-soft); border: 1px solid var(--border-soft); border-radius: 12px; padding: 16px; }
.wb-ai-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.wb-ai-head h4 { margin: 0; }
.wb-ai-panel textarea { width: 100%; min-height: 64px; resize: vertical; }
.wb-ai-options { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.wb-ai-options label { display: inline-flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--text-muted); }
.wb-ai-options select, .wb-ai-options input { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border-soft); background: var(--bg-card); color: var(--text-primary); }
.wb-ai-actions { display: flex; gap: 8px; }

.wb-ai-progress { margin-top: 12px; padding: 12px; border: 1px solid var(--border-soft); border-radius: 10px; background: var(--bg-soft); }

/* ---- AI 写作陪伴助手 ---- */
.wb-ai-companion { padding: 10px 12px; margin-bottom: 12px; border: 1px solid var(--border-soft); border-radius: 10px;
  background: var(--bg-soft); }
.wb-ai-companion-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.wb-ai-companion-icon { display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--bg-soft); color: var(--brand-primary); font-size: 0.85rem; }
.wb-ai-companion-title { font-weight: 600; font-size: 0.92rem; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wb-ai-companion-stage { font-size: 0.98rem; color: var(--text-primary); line-height: 1.55; }
.wb-ai-companion-hint { margin-top: 4px; font-size: 0.85rem; color: var(--text-muted); line-height: 1.55; min-height: 1.3em; }
.wb-ai-companion-steps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.wb-ai-step { font-size: 0.78rem; padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--border-soft); color: var(--text-muted); background: rgba(255,255,255,0.03); }
.wb-ai-step.active { color: var(--brand-primary); border-color: var(--border-strong); background: var(--bg-soft); }
.wb-ai-step.done { color: var(--success); border-color: var(--success-soft); background: var(--success-soft); }
.wb-ai-companion-resume { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.wb-ai-progress-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.wb-ai-progressbar { position: relative; height: 10px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; }
.wb-ai-progressfill { position: absolute; inset: 0 auto 0 0; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
  transition: width 0.4s ease; }
.wb-ai-progress-pct { font-size: 0.85rem; color: var(--text-muted); }
.wb-ai-livepreview { margin-top: 10px; max-height: 220px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  padding: 10px 12px; border: 1px solid var(--border-soft); border-radius: 8px; background: var(--bg-card); color: var(--text-primary); font-size: 0.95rem; line-height: 1.7; }

.wb-toolbar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 8px; background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: 10px; }
.wb-toolbar button { padding: 5px 9px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--text-primary); cursor: pointer; font-size: 0.85rem; }
.wb-toolbar button:hover { background: var(--bg-hover, var(--bg-soft)); border-color: var(--border-soft); }
.wb-tb-sep { width: 1px; height: 20px; background: var(--border-soft); margin: 0 4px; }

.wb-mode-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.wb-mode-group { display: flex; gap: 4px; }
.wb-mode-btn { padding: 6px 12px; border: 1px solid var(--border-soft); background: transparent; color: var(--text-muted); border-radius: 8px; cursor: pointer; font-size: 0.85rem; }
.wb-mode-btn.active { background: var(--brand-primary, #8b5cf6); color: #fff; border-color: transparent; }
.wb-ai-revise { display: flex; gap: 6px; flex: 1; min-width: 0; }
.wb-ai-revise input { flex: 1; }

.wb-content-wrap { position: relative; }
.wb-editable { min-height: 50vh; max-height: 70vh; overflow: auto; padding: 16px; background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: 10px; line-height: 1.8; outline: none; color: var(--text-primary); }
.wb-editable:focus { border-color: var(--brand-primary, #8b5cf6); box-shadow: 0 0 0 2px var(--bg-soft); }
.wb-editable h1, .wb-editable h2, .wb-editable h3, .wb-editable h4 { margin: 0.6em 0 0.3em; line-height: 1.3; }
.wb-editable p { margin: 0.4em 0; }
.wb-editable ul, .wb-editable ol { margin: 0.4em 0 0.4em 1.4em; padding: 0; }
.wb-editable blockquote { margin: 0.6em 0; padding: 6px 14px; border-left: 3px solid var(--brand-primary, #8b5cf6); background: var(--bg-soft); }
.wb-editable table { border-collapse: collapse; width: 100%; margin: 0.6em 0; }
.wb-editable th, .wb-editable td { border: 1px solid var(--border-soft); padding: 6px 10px; }
.wb-editable th { background: var(--bg-soft); }
.wb-editable a { color: var(--brand-primary, #8b5cf6); }
.wb-editable pre { background: var(--bg-soft); padding: 10px; border-radius: 8px; overflow: auto; white-space: pre-wrap; }
.wb-editable code { font-family: Consolas, monospace; background: var(--bg-soft); padding: 1px 5px; border-radius: 4px; }

.wb-preview { min-height: 50vh; padding: 16px; background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: 10px; overflow: auto; }
.wb-source { width: 100%; min-height: 50vh; padding: 14px; background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: 10px; font-family: Consolas, monospace; color: var(--text-primary); line-height: 1.6; }

.wb-footer { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.wb-footer .form-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.wb-export-box { max-width: 480px; }
.wb-export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.wb-export-grid a { text-align: center; }

.ai-status-error { color: var(--danger); }

@media (max-width: 640px) {
  .wb-ai-options { flex-direction: column; }
  .wb-ai-options label { width: 100%; }
  .wb-ai-revise { flex-direction: column; }
  .wb-footer { flex-direction: column; align-items: stretch; }
  .wb-footer .form-actions { justify-content: space-between; }
  .wb-export-grid { grid-template-columns: 1fr; }
  .wb-ai-companion { padding: 8px 10px; }
  .wb-ai-companion-stage { font-size: 0.92rem; }
  .wb-ai-companion-hint { font-size: 0.82rem; }
  .wb-ai-step { font-size: 0.74rem; padding: 2px 7px; }
}

/* Shared compact layouts and component polish. */
.card, .form-card, .stat-card, .table-wrap, .wb-ai-panel, .wb-editable, .wb-preview, .wb-source { box-shadow: var(--shadow-soft); }
.card-title, .post-title { -webkit-text-fill-color: var(--text-primary); }
.btn-primary:hover { box-shadow: var(--shadow-hover); }
.btn-ghost:hover, .wb-toolbar button:hover { background: var(--bg-hover); }
.search-input:focus, .form-card input:focus, .form-card textarea:focus, .form-card select:focus, .wb-editable:focus { box-shadow: var(--focus-ring); }
.badge-draft { color: var(--warning); }.badge-published { color: var(--success); }
.empty-state { border-style: solid; box-shadow: var(--shadow-soft); }
.table-wrap { max-width: 100%; }
.wb-toolbar button { min-height: 34px; }
.wb-ai-revise input { width: 100%; min-height: 42px; padding: 10px 12px; border: 1px solid var(--border-soft); border-radius: 10px; background: var(--bg-card); color: var(--text-primary); font: inherit; font-size: .85rem; }
.wb-ai-panel { background: var(--bg-soft); }
.wb-ai-step.active { background: var(--bg-hover); }
.wb-ai-step.done { background: var(--success-soft); }
.wb-mode-btn.active { background: var(--brand-primary); color: white; }
.article { color: var(--text-primary); line-height: 1.95; }
.article pre { background: var(--code-bg); border-color: var(--code-bg); }
.article pre code, .article pre code.hljs { background: transparent; color: var(--code-text); }
.article table, .wb-editable table { display: block; max-width: 100%; overflow-x: auto; }
.article blockquote { background: var(--bg-soft); border-left-color: var(--brand-accent); }
.seo-body .post-header::after { content: '小羽陪你读一会儿'; display: block; color: var(--brand-primary); font-size: .8rem; margin: 14px 0; }
@media(max-width:640px) {
 .xy-companion-strip { align-items: flex-start; margin-top: 18px; gap: 10px; }
 .xy-companion-strip a { display: none; }.xy-companion-strip p { font-size: .72rem; }
 .xy-companion-strip strong { font-size: .85rem; }
 .xy-article-fields { grid-template-columns: minmax(0,1fr); }
 .wb-title-input-wrap { flex-basis: 100%; }
 .wb-ai-revise { width: 100%; flex: 1 0 100%; }
 .wb-mode-bar > *, .form-actions > * { max-width: 100%; }
 .form-card { padding: 18px; }.preview-overlay .preview-box { padding: 16px; }
 .search-bar { min-width: 0; width: 100%; }.search-input { min-width: 0; width: 100%; }
 .section-en { letter-spacing: .06em; margin-left: 6px; font-size: .58em; }
}
@media(prefers-reduced-motion:reduce) {
 html { scroll-behavior: auto; }
 *, *::before, *::after { animation: none!important; transition: none!important; scroll-behavior: auto!important; }
}

/* ============================================================
   灵动代码（#/code-viz）：内嵌 Python 可视化演示页
   —— 阶段一最小实现：代码输入框 + 示例 + 「动画演示」按钮 + iframe
   —— 可视化模块本体是 code-viz 项目的单文件构建产物，静态托管于
      public/code-viz/index.html，经 postMessage 接收代码
   ============================================================ */
.code-viz-page { max-width: 1080px; margin: 0 auto; }
.cv-desc { color: var(--text-dim); font-size: 0.95rem; margin: 4px 0 18px; }
.cv-desc code {
  font-family: var(--font-mono);
  color: var(--cyan);
  background: rgba(96, 212, 255, 0.1);
  padding: 1px 6px;
  border-radius: 6px;
}
.cv-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cv-code {
  width: 100%;
  min-height: 132px;
  resize: vertical;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.92rem;
  line-height: 1.6;
  padding: 12px 14px;
}
.cv-code:focus { outline: none; border-color: var(--border-glow); }
.cv-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
#cv-status { flex: 1; min-width: 160px; }
.cv-frame {
  width: 100%;
  height: min(72vh, 720px);
  min-height: 420px;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #0b1220; /* 与可视化模块深色主题一致，避免加载闪白 */
  display: block;
}
@media (max-width: 640px) {
  .cv-frame { height: 66vh; min-height: 380px; }
  .cv-code { min-height: 108px; }
