/* tulpa.world 夜空黑主题 */

:root {
  --bg: #070b14;
  --bg-deep: #04060c;
  --nav-bg: rgba(10, 14, 26, 0.85);
  --card: #0e1526;
  --card-soft: #111a30;
  --border: rgba(148, 163, 200, 0.14);
  --text: #e8ecf5;
  --text-sub: #8b95ab;
  --primary: #6c8cff;
  --primary-hover: #5878f0;
  --danger: #f2555a;
  --danger-hover: #e04045;
  --gray-avatar: #3a4256;
  --caret: #ffffff;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  --bg-image: radial-gradient(ellipse at 50% -10%, #0d1428 0%, #070b14 45%, #04060c 100%);
}

/* 浅色主题变量由后端按主题注入（<style id="theme-vars">），此处不再硬编码。
   仅保留 light-mode 的行为规则：浅色主题隐藏旋转星轨。 */
.light-mode .star-tracks { display: none; }

/* 灰烬主题：飘落灰粒 canvas（默认隐藏，仅灰烬主题显示）；灰烬不用旋转星轨 */
.star-fall-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  display: none;
}
.ash-mode .star-fall-canvas { display: block; }
.ash-mode .star-tracks { display: none; }

/* 自定义主题背景效果 */
/* 流星：canvas 拖尾（默认隐藏，仅 th-meteor 显示）；流星时隐藏星轨 */
.meteor-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  display: none;
}
.th-meteor .meteor-canvas { display: block; }
.th-meteor .star-tracks { display: none; }
/* 自定义主题：默认隐藏星轨（纯色/流星都不显示），仅「星轨」效果时强制显示 */
.th-custom .star-tracks { display: none; }
.th-star .star-tracks { display: block; }
.th-star.light-mode .star-tracks { display: block; }

/* ── 用户背景图层（位于 bg-color/星轨/灰烬 下层） ── */
.theme-bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
}
.theme-bg-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg);
  /* 上层颜色遮罩：背景图越不透明（opacity 越高），遮罩越淡 */
  opacity: calc(1 - var(--bg-img-opacity, 0.45));
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-variant-emoji: text;
  background-color: var(--bg);
  background-image: var(--bg-image);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── 星轨（巨大的星盘缓慢盘旋） ── */
.star-tracks {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.star-disk {
  position: absolute;
  left: -120vmax;
  top: -120vmax;
  width: 240vmax;
  height: 240vmax;
  transform: rotate(0deg);
  will-change: transform;
  animation: star-spin 720s linear infinite;
}
@keyframes star-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .star-disk { animation: none; }
}

/* ── 导航 ── */
.site-nav {
  background: var(--nav-bg);
  /* 避免 backdrop-filter blur 在有 canvas 背景动画的主题下每帧重算模糊 */
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.nav-inner-search .nav-search { flex: 1; max-width: 380px; display: flex; }
.nav-search { position: relative; }
.nav-search-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 999px 0 0 999px;
  background: var(--card-soft);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 8px 14px;
  outline: none;
}
.nav-search-input:focus { border-color: var(--primary); }
.nav-search-btn {
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 999px 999px 0;
  background: var(--card);
  color: var(--text-sub);
  font-size: 13px;
  font-family: inherit;
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
}
.nav-search-btn:hover { color: var(--text); }
.nav-brand {
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
}
.nav-brand:hover { text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-link {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
}
.nav-link:hover { background: rgba(255, 255, 255, 0.06); text-decoration: none; }
.nav-link-solid {
  background: var(--primary);
  color: #fff;
}
.nav-link-solid:hover { background: var(--primary-hover); }

/* ── 顶栏头像菜单 ── */
.nav-user { position: relative; }
.nav-user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 3px 6px 3px 3px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}
.nav-user-btn:hover { border-color: var(--border); background: rgba(255, 255, 255, 0.04); }
.nav-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}
img.nav-avatar.avatar-img { object-fit: cover; }
.nav-user-name {
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-caret {
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-sub);
}
.nav-unread-dot {
  position: absolute;
  top: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e5484d;
  border: 2px solid var(--nav-bg, #0a0e1a);
  box-sizing: content-box;
}
.nav-user-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 520px;
  max-height: min(80vh, 620px);
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  padding: 6px;
  z-index: 200;
}
/* ── Mega Nav 头部用户身份卡 ── */
.nav-mega-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 4px;
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
}
.nav-mega-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.nav-mega-user-info {
  min-width: 0;
}
.nav-mega-name {
  font-weight: 700;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-mega-role {
  display: inline-block;
  margin-top: 2px;
}
/* ── Mega Nav 主列网格 ── */
.nav-mega-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  padding: 4px 0;
}
.nav-mega-col {
  padding: 0 4px;
}
.nav-mega-group {
  padding: 6px 0 2px;
}
.nav-mega-group + .nav-mega-group {
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.nav-mega-title {
  font-size: 11px;
  color: var(--text-sub);
  padding: 4px 8px 6px;
  letter-spacing: 0.4px;
  font-weight: 700;
}
.nav-mega-link {
  display: block;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s;
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  box-sizing: border-box;
}
.nav-mega-link:hover {
  background: rgba(255, 255, 255, 0.06);
  text-decoration: none;
}
.nav-mega-link-danger { color: var(--danger); }
.nav-mega-link-danger:hover { background: rgba(229, 72, 77, 0.12); }
/* 未读消息红泡泡（收件箱行内） */
.nav-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 14px;
  height: 14px;
  padding: 0 4px;
  border-radius: 7px;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  margin-left: 5px;
  vertical-align: 1px;
  box-sizing: border-box;
}
/* 创作组预留空行（占位保持列高一致） */
.nav-mega-empty {
  height: 33px;
  pointer-events: none;
}
/* ── 管理行（横向 pill 排列） ── */
.nav-mega-admin {
  border-top: 1px solid var(--border);
  margin-top: 2px;
  padding: 8px 10px 6px;
}
.nav-mega-admin-title {
  font-size: 11px;
  color: var(--text-sub);
  letter-spacing: 0.4px;
  margin-bottom: 6px;
  font-weight: 700;
}
.nav-mega-admin-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.nav-mega-admin-link {
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-sub);
  border: 1px solid var(--border);
  border-radius: 999px;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}
.nav-mega-admin-link:hover {
  color: var(--primary);
  border-color: var(--primary);
  text-decoration: none;
}
/* ── 身份切换（横向滚动/折行，适应大量子账号） ── */
.nav-mega-identity {
  border-top: 1px solid var(--border);
  margin-top: 2px;
  padding: 8px 10px 6px;
}
.nav-mega-identity-title {
  font-size: 11px;
  color: var(--text-sub);
  letter-spacing: 0.4px;
  margin-bottom: 6px;
  font-weight: 700;
}
.nav-mega-identity-form { margin: 0; }
/* 身份按钮约 30px/行，120px ≈ 4 行后内滚，避免面板被大量子账号撑爆 */
.nav-mega-identity-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 120px;
  overflow-y: auto;
}
.nav-mega-identity-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.nav-mega-identity-btn:hover { background: rgba(255, 255, 255, 0.06); }
.nav-mega-identity-btn.current {
  background: rgba(108, 140, 255, 0.1);
  border-color: rgba(108, 140, 255, 0.3);
}
.nav-mega-identity-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100px;
}
/* ── Mega Nav 底部 ── */
.nav-mega-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  margin-top: 2px;
  padding: 6px 8px;
}
.nav-mega-foot-left {
  display: flex;
  gap: 4px;
}
.nav-mega-foot-right {
  display: flex;
  gap: 4px;
}

/* 旧下拉导航残留的仍在用类：退出表单 + 浅色主题 hover 微调 */
.nav-logout-form { margin: 0; }
.light-mode .nav-user-btn:hover { border-color: rgba(0,0,0,0.15); background: rgba(0,0,0,0.04); }
.light-mode .nav-mega-link:hover { background: rgba(0,0,0,0.05); }
.light-mode .nav-mega-identity-btn:hover { background: rgba(0,0,0,0.05); }

/* ── 主区域 ── */
.site-main { flex: 1; width: 100%; position: relative; z-index: 1; }
.site-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 24px;
  color: var(--text-sub);
  font-size: 13px;
}

/* ── 按钮 ── */
.btn {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap; /* 防止按钮内文字换行 */
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; }
.btn-secondary { background: var(--card); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--card-soft); }
.btn-danger { background: var(--card); border-color: var(--border); color: var(--danger); }
.btn-danger:hover { background: rgba(242, 85, 90, 0.1); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: var(--danger-hover); }
.btn-warning { background: #f5a623; border-color: #f5a623; color: #fff; }
.btn-warning:hover { background: #e0951a; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn:disabled,
.btn.disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ── 表单 ── */
.form-field { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--card-soft);
  color: var(--text);
}
.form-input:focus { outline: none; border-color: var(--primary); }
.form-input:disabled { background: rgba(255, 255, 255, 0.04); color: var(--text-sub); }
.form-textarea { min-height: 90px; resize: vertical; }
.form-row { display: flex; gap: 8px; }
.form-hint { font-size: 12px; color: var(--text-sub); margin-top: 5px; display: block; }
.form-error {
  background: rgba(242, 85, 90, 0.1);
  border: 1px solid rgba(242, 85, 90, 0.35);
  color: #ff8a8e;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 16px;
}
.form-success {
  background: rgba(46, 160, 67, 0.12);
  border: 1px solid rgba(46, 160, 67, 0.35);
  color: #7ee787;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 16px;
}

/* ── 认证页 ── */
.auth-wrap {
  max-width: 420px;
  margin: 0 auto;
  padding: 60px 20px;
}
.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}
.auth-title { font-size: 24px; font-weight: 700; }
.auth-sub { color: var(--text-sub); font-size: 14px; margin: 6px 0 24px; }
.auth-switch { text-align: center; font-size: 14px; color: var(--text-sub); margin-top: 20px; }

/* ── 注册子账号 ── */
.sub-account-box { margin-top: 8px; }
.sub-title { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.sub-hint { font-size: 13px; color: var(--text-sub); margin-bottom: 18px; }
.skip-link {
  display: block;
  text-align: center;
  font-size: 14px;
  margin-top: 16px;
}

.sub-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

/* ── 页面容器 ── */
.page-wrap { max-width: 720px; margin: 0 auto; padding: 32px 20px 60px; }
.page-wrap-wide { max-width: 1320px; margin: 0 auto; padding: 32px 20px 60px; } /* 宽页：文档/私聊/管理后台等 */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap; /* 窄屏时标题与按钮自动换行，避免挤压 */
}
.page-title { font-size: 24px; font-weight: 700; min-width: 0; word-break: break-word; }
.page-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── 头像 ── */
.avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 600;
  color: #fff;
  user-select: none;
  flex-shrink: 0;
}
.avatar-sm { width: 44px; height: 44px; font-size: 18px; }
.avatar-xs { width: 28px; height: 28px; font-size: 12px; }
/* 讨论区回复头像：直径 96px 的 1/3 → 32px（半径 48→16px） */
.avatar-answer { width: 32px; height: 32px; font-size: 14px; }
.avatar-default {
  background: var(--gray-avatar);
  /* 最简单的灰底形象：纯灰圆 + 名字首字 */
}
.avatar-img { background: var(--bg); }

/* ── 用户页 ── */
.profile-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
/* 身份卡布局：左侧头像、右侧名称/简介内容（横向，窄屏不竖排） */
.profile-head { display: flex; gap: 20px; align-items: flex-start; }
.profile-head-avatar { flex: 0 0 auto; }
.profile-head-avatar .avatar { width: 70px; height: 70px; font-size: 28px; }
.profile-head-main { flex: 1 1 auto; min-width: 0; }
/* 名称右侧身份泡泡：主账号/子账号 */
.profile-name { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; word-break: break-word; }
.id-bubble {
  display: inline-block;
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  color: #fff;
  background: var(--primary);
  padding: 3px 8px;
  border-radius: 999px;
  vertical-align: middle;
}
.avatar-btn {
  position: relative;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
  flex-shrink: 0;
}
.avatar-edit-hint {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}
.avatar-btn:hover .avatar-edit-hint { opacity: 1; }
@media (max-width: 640px) {
  .profile-head { gap: 12px; }
  .profile-head-avatar .avatar { width: 48px; height: 48px; font-size: 20px; }
}
/* 名称/简介行：内容居左、灰色「修改」字居卡片右侧，同行 */
.profile-lines { display: flex; flex-direction: column; gap: 12px; }
.profile-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.profile-line h2 { font-size: 20px; font-weight: 700; margin: 0; word-break: break-word; }
.profile-line p { margin: 0; color: var(--text-sub); font-size: 14px; line-height: 1.6; word-break: break-word; white-space: pre-wrap; }
.profile-edit-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
  color: var(--text-sub);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.profile-edit-btn:hover { color: var(--primary); text-decoration: underline; }
/* 用户页：底部操作栏（查看公开主页 + 退出） */
.profile-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ── 标签 ── */
.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  vertical-align: middle;
}
.tag-main { background: rgba(108, 140, 255, 0.15); color: #9db4ff; }
.tag-member { background: rgba(255, 255, 255, 0.07); color: var(--text-sub); }
.tag-current { background: rgba(46, 160, 67, 0.15); color: #7ee787; }
.tag-warning { background: rgba(219, 157, 53, 0.15); color: #dbb44a; }

/* ── 成员管理 ── */
.member-list { display: flex; flex-direction: column; gap: 10px; }
.member-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.member-row.is-current { border-color: var(--primary); }
.member-avatar { flex-shrink: 0; }
.member-info { flex: 1; min-width: 0; }
.member-name { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.member-bio { font-size: 13px; color: var(--text-sub); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-actions { display: flex; gap: 8px; flex-shrink: 0; }
.member-empty {
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  color: var(--text-sub);
  font-size: 14px;
}

/* ── 底部管理区（低调） ── */
.member-bottom {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.btn-ghost {
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
}
.btn-ghost:hover { color: var(--text); }

/* ── 头像裁剪弹窗 ── */
.crop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.crop-overlay[hidden] { display: none; }
.crop-modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 420px;
  max-width: calc(100vw - 40px);
}
.crop-title { font-size: 17px; font-weight: 700; }
.crop-hint { font-size: 13px; color: var(--text-sub); margin: 4px 0 14px; }
.crop-stage {
  background: #04060c;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  padding: 8px;
}
.crop-stage canvas { max-width: 100%; touch-action: none; cursor: grab; }
.crop-controls { margin: 14px 0 4px; }
.crop-slider-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-sub);
}
.crop-slider-label input { flex: 1; accent-color: var(--primary); }
.crop-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }

/* ── 文档：搜索 + 文章列表 ── */
.docs-search {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.docs-search .form-input { flex: 1; }
.article-list { display: flex; flex-direction: column; }
.article-item {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 12px;
  transition: border-color 0.15s;
  flex-wrap: wrap;
}
.article-item:hover { border-color: var(--primary); }
.article-item-link {
  flex: 1;
  min-width: 0;
  color: var(--text);
}
.article-item-link:hover { text-decoration: none; }
.article-item-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.article-title { font-size: 18px; font-weight: 700; line-height: 1.4; }
.article-summary {
  color: var(--text-sub);
  font-size: 14px;
  margin-top: 8px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.article-meta { color: var(--text-sub); font-size: 12px; margin-top: 10px; }

/* ── 文章详情 ── */
.article-detail {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 40px;
  margin-bottom: 20px;
  min-height: calc(100vh - 56px - 92px); /* 铺满屏幕：视口 - 导航 - 上下边距 */
  display: flex;
  flex-direction: column;
}
.article-detail-title { font-size: 26px; font-weight: 800; line-height: 1.4; }
.article-detail-meta { color: var(--text-sub); font-size: 13px; margin-top: 10px; }
.article-detail-summary {
  color: var(--text-sub);
  font-size: 15px;
  line-height: 1.7;
  margin-top: 18px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid var(--primary);
  border-radius: 0 8px 8px 0;
}
.article-detail-content {
  font-size: 15px;
  line-height: 1.9;
  margin-top: 24px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── 我的卡片（个人短篇） ── */
.my-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 28px;
  margin-top: 20px;
}
.my-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.my-card-title { font-size: 17px; font-weight: 700; }
.my-card-link { font-size: 13px; color: var(--text-sub); }
.my-card-link:hover { color: var(--primary); }
.my-stories { display: flex; flex-direction: column; margin-bottom: 16px; }
.my-story {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
}
.my-story:hover { background: rgba(255, 255, 255, 0.05); text-decoration: none; }
.my-story-title {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.my-story-date { color: var(--text-sub); font-size: 12px; flex-shrink: 0; }
.my-story-empty {
  color: var(--text-sub);
  font-size: 13px;
  padding: 10px 12px;
}

/* ── 短篇编辑器 ── */
.editor-form { display: flex; flex-direction: column; }
.editor-title { font-size: 18px; font-weight: 600; }
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}
.tool-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-soft);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.tool-btn:hover { border-color: var(--primary); }
.tool-italic { font-style: italic; }
.tool-underline { text-decoration: underline; }
.tool-strikethrough { text-decoration: line-through; }
.tool-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.toolbar-spacer { flex: 1; }
.tool-size-select {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-soft);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  min-width: 72px;
}
.tool-size-select:focus { border-color: var(--primary); }
.tool-size-select option { background: var(--card); color: var(--text); }
.editor-area {
  min-height: 420px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--card);
  font-size: 15px;
  line-height: 1.9;
  outline: none;
  overflow-y: auto;
  word-break: break-word;
  caret-color: var(--caret);
}
.editor-area:focus { border-color: var(--primary); }
.editor-area:empty::before {
  content: attr(data-placeholder);
  color: var(--text-sub);
  pointer-events: none;
}
.editor-area img { display: block; max-width: 100%; height: auto; border-radius: 6px; }
/* ── Markdown 编辑器（CodeMirror） ── */
.md-editor { display: flex; flex-direction: column; width: 100%; }
/* 工具栏 */
.md-toolbar, .editor-toolbar { position: relative; z-index: 3; flex-wrap: wrap; }
.md-toolbar .tool-btn[data-img] { color: var(--primary); }

/* CodeMirror 容器：占满宽度、用主题变量着色、底部圆角 */
.md-editor .CodeMirror {
  width: 100%;
  min-height: 420px;
  height: auto;
  font-size: 15px;
  line-height: 1.9;
  font-family: inherit;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
}
.md-editor .CodeMirror-scroll { min-height: 420px; }
.md-editor .CodeMirror-lines { padding: 14px 16px; }
.md-editor .CodeMirror pre.CodeMirror-line,
.md-editor .CodeMirror pre.CodeMirror-line-like {
  padding: 0 4px; /* 光标命中更稳，折叠前留一点内边距 */
}
.md-editor .CodeMirror-selected { background: rgba(108, 140, 255, 0.22); }
.md-editor .CodeMirror-focused .CodeMirror-selected { background: rgba(108, 140, 255, 0.28); }
.md-editor .CodeMirror-cursor {
  border-left: 2px solid var(--caret, var(--text));
  border-right: none;
}
.md-editor .CodeMirror-placeholder { color: var(--text-sub); }
.md-editor .CodeMirror-gutters {
  background: transparent;
  border-right: 0;
}

/* Markdown 语法 token 配色：标记淡蓝、文本保持主题色 */
.md-editor .cm-formatting-header,
.md-editor .cm-formatting-strong,
.md-editor .cm-formatting-em,
.md-editor .cm-formatting-strikethrough,
.md-editor .cm-formatting-quote,
.md-editor .cm-formatting-list,
.md-editor .cm-formatting-code,
.md-editor .cm-formatting-link,
.md-editor .cm-formatting-image,
.md-editor .cm-formatting-task,
.md-editor .cm-formatting-table {
  color: rgba(108, 140, 255, 0.55);
}
.md-editor .cm-header { color: var(--text); }
/* 标题真实字号：标记(#)保持小号淡蓝，正文按级放大。
   CodeMirror 光标按真实排版计算，不会错位。 */
.md-editor .cm-header-1 { font-size: 28px; line-height: 1.4; font-weight: bold; }
.md-editor .cm-header-2 { font-size: 24px; line-height: 1.4; font-weight: bold; }
.md-editor .cm-header-3 { font-size: 20px; line-height: 1.5; font-weight: bold; }
.md-editor .cm-header-4 { font-size: 18px; line-height: 1.5; font-weight: bold; }
.md-editor .cm-header-5 { font-size: 16px; font-weight: bold; }
.md-editor .cm-header-6 { font-size: 15px; font-weight: bold; }
.md-editor .cm-strong { font-weight: bold; color: var(--text); }
.md-editor .cm-em { font-style: italic; color: var(--text); }
.md-editor .cm-strikethrough { text-decoration: line-through; color: var(--text-sub); }
.md-editor .cm-link { color: var(--primary); }
.md-editor .cm-image { color: var(--text-sub); }
.md-editor .cm-url { color: var(--primary); text-decoration: underline; }
.md-editor .cm-quote { color: var(--text-sub); }
.md-editor .cm-comment { color: var(--text-sub); }
.md-editor .cm-keyword { color: var(--text); }
.md-editor .cm-number, .md-editor .cm-string, .md-editor .cm-meta { color: var(--text); }
.md-editor .cm-variable-2 { color: var(--text); }
.md-editor .CodeMirror-activeline-background { background: transparent; }

/* 光标位于图片标记时的 tooltip 预览 */
.md-image-tooltip {
  position: fixed;
  z-index: 5600;
  width: 240px;
  max-height: 180px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  pointer-events: none;
}
.md-image-tooltip[hidden] { display: none; }
.md-image-tooltip img {
  display: block;
  width: 100%;
  max-height: 168px;
  object-fit: contain;
}

/* 底部图片预览栏 */
.md-img-preview-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--card-soft);
}
.md-img-preview-strip[hidden] { display: none; }
.md-preview-item {
  display: block;
  max-width: 180px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
.md-preview-img {
  display: block;
  max-width: 180px;
  max-height: 140px;
  border: 1px solid var(--border);
  border-radius: 6px;
  object-fit: cover;
}
.story-content img { display: block; max-width: 100%; height: auto; border-radius: 6px; }
/* Markdown 表格 */
.md-table-wrap { overflow-x: auto; margin: 12px 0; }
.md-table-wrap table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}
.md-table-wrap th,
.md-table-wrap td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.md-table-wrap th {
  background: var(--card-soft);
  font-weight: 600;
  white-space: nowrap;
}
.img-thumb { object-fit: cover; cursor: pointer; }
.img-wrap { display: block; cursor: pointer; }
.img-wrap:hover { opacity: 0.85; }
/* Skeleton 占位 + Shimmer 加载动画 */
.img-sk {
  display: block;
  position: relative;
  overflow: hidden;
  background: var(--card-soft);
  border-radius: 6px;
  margin: 8px 0;
}
.img-sk::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 30%, rgba(255,255,255,0.06) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  z-index: 0;
  pointer-events: none;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.img-sk img {
  position: relative;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.3s;
  display: block;
  border-radius: 6px;
  /* 强制撑满容器，不被父级 height:auto 覆盖，配合 object-fit 确保非方形图正确渲染 */
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}
.img-sk img.loaded {
  opacity: 1;
}
.img-sk:empty { display: none; }
/* 编辑器图片占位：skeleton + shimmer + 框内进度条（上传中） */
.qa-img-ph {
  position: relative;
  display: inline-block;
  margin: 8px 0;
  vertical-align: baseline;
  border-radius: 6px;
  overflow: hidden;
  background: var(--card-soft);
}
.qa-img-ph::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 30%, rgba(255,255,255,0.08) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  z-index: 0;
}
.qa-img-ph-progress {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 14px;
  height: 5px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1;
  overflow: hidden;
}
.qa-img-ph-bar {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.15s;
}
.qa-img-ph img {
  position: relative;
  z-index: 1;
  display: block;
  opacity: 0;
  transition: opacity 0.3s;
  border-radius: 6px;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}
.qa-img-ph img.loaded { opacity: 1; }
.img-modal { display: none; position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,0.92); cursor: pointer; }
.img-modal-content {
  max-width: none; max-height: none;
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 4px;
  object-fit: contain;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  will-change: transform;
  transition: transform 0.08s ease-out;
}
.img-modal.img-dragging .img-modal-content { cursor: grabbing; transition: none; }
.img-modal-close { position: absolute; top: 16px; right: 24px; color: #fff; font-size: 32px; font-weight: bold; cursor: pointer; z-index: 1; }
body.no-scroll { overflow: hidden; }
.editor-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.story-content { font-size: 16px; line-height: 2; }
/* md 渲染块级样式（story-content / qa-post-content / submission-preview 通用） */
.story-content p, .qa-post-content p, .submission-preview p { margin: 0 0 0.9em; }
.story-content h1, .story-content h2, .story-content h3,
.story-content h4, .story-content h5, .story-content h6,
.qa-post-content h1, .qa-post-content h2, .qa-post-content h3,
.qa-post-content h4, .qa-post-content h5, .qa-post-content h6 {
  margin: 1.2em 0 0.6em;
  line-height: 1.4;
}
.story-content h1, .qa-post-content h1 { font-size: 1.7em; }
.story-content h2, .qa-post-content h2 { font-size: 1.45em; }
.story-content h3, .qa-post-content h3 { font-size: 1.25em; }
.story-content h4, .qa-post-content h4 { font-size: 1.1em; }
.story-content ul, .story-content ol,
.qa-post-content ul, .qa-post-content ol { margin: 0 0 0.9em; padding-left: 1.6em; }
.story-content li, .qa-post-content li { margin: 0.25em 0; }
.story-content blockquote, .qa-post-content blockquote {
  margin: 0 0 0.9em;
  padding: 6px 14px;
  border-left: 3px solid var(--primary);
  background: var(--card-soft);
  color: var(--text-sub);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.story-content pre, .qa-post-content pre {
  margin: 0 0 0.9em;
  padding: 12px 14px;
  background: #161a26;
  color: #dfe3f0;
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.6;
}
.story-content code, .qa-post-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--card-soft);
  padding: 1px 5px;
  border-radius: 4px;
}
.story-content pre code, .qa-post-content pre code { background: none; padding: 0; }
.story-content a, .qa-post-content a { color: var(--primary); text-decoration: underline; }
.story-content hr, .qa-post-content hr { border: none; border-top: 1px solid var(--border); margin: 1.2em 0; }
.story-content del, .qa-post-content del { color: var(--text-sub); }
.story-content .img-wrap, .qa-post-content .img-wrap { display: inline-block; margin: 0.2em 0; }

/* ── Toast 提示 ── */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--card-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.25s, transform 0.25s;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { border-color: rgba(242, 85, 90, 0.45); color: #ff8a8e; }

/* ── 书架分类标签 ── */
.shelf-tabs { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.shelf-tab {
  display: inline-block;
  padding: 10px 20px;
  font-size: 14px;
  color: var(--text-sub);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.shelf-tab:hover { color: var(--text); text-decoration: none; }
.shelf-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── 长篇编辑布局 ── */
.serial-edit-layout { display: flex; gap: 20px; align-items: flex-start; }
.serial-chapter-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.serial-chapter-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
}
.serial-chapter-list { max-height: 60vh; overflow-y: auto; }
.serial-chapter-item {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.serial-chapter-item:last-child { border-bottom: none; }
.serial-chapter-item.active { background: rgba(108, 140, 255, 0.08); }
.serial-chapter-item-link {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 13px;
  min-width: 0;
}
.serial-chapter-item-link:hover { text-decoration: none; color: var(--primary); }
.serial-chapter-num { color: var(--text-sub); flex-shrink: 0; }
.serial-chapter-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.serial-chapter-del {
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 16px;
  padding: 10px 12px;
  cursor: pointer;
  line-height: 1;
}
.serial-chapter-del:hover { color: var(--danger); }
.serial-chapter-empty { padding: 20px; text-align: center; color: var(--text-sub); font-size: 13px; }
.serial-edit-main { flex: 1; min-width: 0; }
.serial-chapter-item-actions { display: flex; flex-shrink: 0; }
.serial-chapter-action-form { display: inline; }
.serial-chapter-action-btn {
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 12px;
  padding: 4px 6px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.serial-chapter-action-btn:hover { color: var(--primary); }

/* ── 长篇阅读章节导航 ── */
.serial-chapter-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}
.serial-chapter-link {
  display: inline-block;
  padding: 6px 14px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  transition: border-color 0.15s;
}
.serial-chapter-link:hover { border-color: var(--primary); text-decoration: none; }
.serial-chapter-link.active { border-color: var(--primary); background: rgba(108, 140, 255, 0.1); color: var(--primary); }

/* ── 章节底部导航 ── */
.chapter-nav-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.chapter-nav-info { color: var(--text-sub); font-size: 14px; }

/* ── 问答 ── */
.qa-list { display: flex; flex-direction: column; gap: 10px; }
.qa-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  transition: border-color 0.15s;
}
.qa-item:hover { border-color: var(--primary); }
.qa-item-main { flex: 1; min-width: 0; }
.qa-item-title {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qa-item-title:hover { color: var(--primary); text-decoration: none; }
.qa-item-meta { color: var(--text-sub); font-size: 13px; margin-top: 6px; }

.qa-post {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.qa-post-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.qa-post-author { min-width: 0; }
.qa-post-name { font-size: 15px; font-weight: 600; }
.qa-post-date { color: var(--text-sub); font-size: 12px; margin-top: 2px; }
.qa-post-content { font-size: 16px; line-height: 2; word-break: break-word; }
.qa-post-actions { display: flex; gap: 16px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.qa-action-btn {
  background: none; border: none; color: var(--text-sub); font-size: 13px; cursor: pointer;
  padding: 4px 0; font-family: inherit; white-space: nowrap;
}
.qa-action-btn:hover { color: var(--text); }
/* 评论区上方的作品互动条：去掉顶部边框，用底部边框与评论区隔开 */
.work-actions-above { margin-top: 0; padding-top: 0; border-top: none; border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 20px; }
/* 点赞点亮（红） */
.qa-like-btn.liked { color: #ff4d4f; font-weight: 600; }
.qa-like-btn.liked:hover { color: #ff7875; }
/* 收藏点亮（蓝）——与点赞对称 */
.qa-fav-btn.faved { color: #2b7de9; font-weight: 600; }
.qa-fav-btn.faved:hover { color: #5a9cf5; }

.qa-answer-title { font-size: 17px; margin: 24px 0 14px; }
.qa-answers { display: flex; flex-direction: column; gap: 14px; }
.qa-answer {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.qa-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}
.qa-toolbar-hint { color: var(--text-sub); font-size: 12px; }
.qa-answer-form-wrap { margin-top: 24px; }
.qa-login-hint {
  text-align: center;
  color: var(--text-sub);
  padding: 30px 0;
  border-top: 1px solid var(--border);
  margin-top: 24px;
}

/* ── 用户页分隔线 ── */
.my-divider { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.my-card-subtitle { font-size: 13px; color: var(--text-sub); margin: 12px 0 8px; font-weight: 600; }

@media (max-width: 640px) {
  /* 移动端导航：品牌一行，搜索框第二行整宽，导航菜单第三行 */
  .nav-inner {
    flex-direction: column;
    justify-content: center;
    height: auto;
    padding: 8px 14px 10px;
    gap: 6px;
  }
  .nav-inner-search .nav-search { flex: none; width: 100%; max-width: none; }
  .nav-brand { font-size: 16px; }
  .nav-links {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
  }
  .nav-link { padding: 6px 12px; font-size: 13px; }
  .nav-user-name { display: none; } /* 窄屏只显头像 */
  .nav-user-panel {
    position: fixed;
    right: 10px;
    top: 64px;
    width: min(480px, calc(100vw - 20px));
  }
  .member-row { flex-wrap: wrap; }
  .member-actions { width: 100%; justify-content: flex-end; }
}

/* ── 主题设置页 ── */
.settings-identity { margin-bottom: 6px; font-size: 15px; }
.settings-identity-hint { color: var(--text-sub); font-size: 13px; margin-top: 4px; margin-bottom: 20px; }
.settings-section-title { font-size: 16px; font-weight: 700; margin: 24px 0 14px; }
.scheme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
}
.scheme-card {
  border: 1px solid var(--border);
  background: var(--card-soft);
  border-radius: var(--radius);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.15s, transform 0.1s;
}
.scheme-card:hover { border-color: var(--primary); }
.scheme-card.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.scheme-swatch {
  width: 36px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--swatch, var(--primary));
}
.scheme-name { line-height: 1.2; text-align: center; }
.custom-color-input {
  width: 64px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-soft);
  cursor: pointer;
  padding: 2px;
}
.settings-divider { border: none; border-top: 1px solid var(--border); margin: 26px 0; }
.bg-upload-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.bg-upload-btn { display: inline-block; margin: 0; }
.bg-upload-btn.btn-loading { opacity: 0.7; cursor: wait; pointer-events: none; }
.bg-upload-progress {
  flex: 0 0 180px;
  height: 6px;
  border-radius: 3px;
  background: var(--card-soft);
  border: 1px solid var(--border);
  overflow: hidden;
}
.bg-upload-progress-bar {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.15s;
}
.bg-preview { margin-top: 16px; }
.bg-preview img {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: block;
  margin-bottom: 12px;
  opacity: 0;
  transition: opacity 0.3s;
}
.bg-preview img.loaded { opacity: 1; }
/* 上传中：隐藏旧图与操作行，仅显示 skeleton+shimmer */
.bg-preview.uploading > img,
.bg-preview.uploading .bg-preview-actions { display: none; }
.bg-preview.uploading .bg-skeleton { display: block; }
.bg-skeleton {
  position: relative;
  display: none;
  width: 100%;
  max-width: 420px;
  height: 200px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--card-soft);
  margin-bottom: 12px;
}
.bg-skeleton::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 30%, rgba(255,255,255,0.08) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}
.bg-opacity-label { margin: 0; display: flex; align-items: center; gap: 8px; }
.bg-opacity-label span { color: var(--text); font-size: 13px; min-width: 38px; }
input[type="range"] { accent-color: var(--primary); }
@media (max-width: 560px) {
  .scheme-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ── 自定义效果 segmented ── */
.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  background: var(--card-soft);
  flex-wrap: wrap;
}
.seg-item {
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-sub);
  padding: 7px 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg-item + .seg-item { border-left: 1px solid var(--border); }
.seg-item.active { background: var(--primary); color: #fff; }

/* ── 文档审核 ── */
.submission-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.submission-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.submission-title { font-size: 17px; font-weight: 700; }
.submission-meta { color: var(--text-sub); font-size: 13px; margin-bottom: 10px; }
.submission-preview {
  max-height: 220px; overflow: auto;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 16px; margin-bottom: 12px;
  background: var(--card-soft);
  font-size: 14px; line-height: 1.8;
  color: var(--text-sub);
}
.tag-pending { background: rgba(245, 166, 35, 0.15); color: #f5a623; }
.tag-ok { background: rgba(46, 160, 67, 0.15); color: #7ee787; }
.tag-reject { background: rgba(242, 85, 90, 0.15); color: #ff8a8e; }

/* ── 文档审核员行 ── */
.reviewer-line {
  margin-top: 24px;
  padding: 10px 14px;
  border-left: 3px solid var(--primary);
  background: var(--card-soft);
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  color: var(--text-sub);
  font-family: ui-monospace, "SF Mono", "Fira Code", Consolas, monospace;
}
.reviewer-label { font-weight: 700; margin-right: 8px; color: var(--primary); font-family: inherit; }
.reviewer-id { word-break: break-all; }

/* ── 文档操作栏 ── */
.article-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 20px;
}

/* ── 举报弹窗 ── */
.report-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 6px 0 14px;
}
.report-reason {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  cursor: pointer;
}
.report-reason input { accent-color: var(--primary); }

/* ── 举报处理 ── */
.submission-reason {
  background: var(--card-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.7;
}
.report-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
/* ── 管理操作红色确认 modal ── */
.danger-overlay {
  position: fixed;
  inset: 0;
  background: rgba(60, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
}
.danger-overlay[hidden] { display: none; }
.danger-modal {
  background: var(--card);
  border: 1px solid rgba(242, 85, 90, 0.6);
  border-radius: var(--radius);
  padding: 24px;
  width: 400px;
  max-width: calc(100vw - 40px);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}
.danger-title { font-size: 17px; font-weight: 700; color: var(--danger); margin-bottom: 10px; }
.danger-message {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 18px;
  white-space: pre-wrap;
  word-break: break-word;
}
.danger-actions { margin-top: 0; }

/* ── 管理后台：审核员管理 ── */
.auditor-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
}
.auditor-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.auditor-name { font-size: 15px; font-weight: 600; }
.auditor-email { color: var(--text-sub); font-size: 13px; }
.auditor-grants { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.auditor-modules { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-bottom: 12px; }
.auditor-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── 管理后台：用户列表 ── */
.user-table { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.user-table-head { display: flex; background: var(--card); padding: 10px 16px; font-size: 12px; font-weight: 700; color: var(--text-sub); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); gap: 12px; }
.user-row { display: flex; align-items: center; padding: 12px 16px; gap: 12px; background: var(--card); border-bottom: 1px solid var(--border); font-size: 14px; }
.user-row:last-child { border-bottom: none; }
.user-row:hover { background: rgba(255,255,255,0.03); }
.user-col-name { flex: 2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.user-col-email { flex: 3; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-sub); font-size: 13px; }
.user-col-role { flex: 1; min-width: 80px; }
.user-col-members { flex: 0 0 60px; text-align: center; color: var(--text-sub); }
.user-col-date { flex: 0 0 100px; color: var(--text-sub); font-size: 13px; }

/* ── 管理后台：审计日志 ── */
.log-list { display: flex; flex-direction: column; gap: 8px; }
.log-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.log-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.log-action {
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  color: var(--primary);
  background: rgba(108, 140, 255, 0.1);
  padding: 2px 8px;
  border-radius: 999px;
}
.log-actor { font-size: 13px; font-weight: 600; }
.log-target { font-size: 12px; color: var(--text-sub); }
.log-detail {
  font-size: 12px;
  color: var(--text-sub);
  flex: 1;
  min-width: 0;
  word-break: break-all;
}
.log-time { font-size: 12px; color: var(--text-sub); flex-shrink: 0; }

/* ── 管理后台：分类/板块 ── */
.category-list { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.category-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.category-name { font-size: 15px; font-weight: 600; flex-shrink: 0; }
.category-rename { display: flex; gap: 8px; align-items: center; flex: 1; min-width: 200px; }
/* 分类/板块排序按钮：竖排两枚小按钮，居左 */
.category-order-btns {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.category-order-btn {
  line-height: 1;
  padding: 2px 8px;
  font-size: 13px;
}

/* ── 置顶标记 ── */
.pin-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: #f5a623;
  padding: 1px 7px;
  border-radius: 4px;
  vertical-align: middle;
  margin-right: 6px;
}
.pin-btn.pinned {
  /* 置顶中：橙色描边 + 透明底 + 橙字（区别于未置顶的实心橙按钮） */
  background: transparent;
  color: #f5a623;
  border-color: #f5a623;
}
.pin-btn.pinned:hover { background: rgba(245, 166, 35, 0.12); }

/* ── 分类/板块侧边栏布局：宽屏左侧常驻 drawer，窄屏顶部 tab ── */
.cat-layout { display: flex; gap: 20px; align-items: flex-start; }
.cat-layout-main { flex: 1; min-width: 0; }
.cat-drawer {
  width: 190px;
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}
.cat-drawer-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
  padding: 4px 10px 10px;
  letter-spacing: 0.05em;
}
.cat-drawer-item {
  display: block;
  padding: 8px 12px;
  margin: 2px 0;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.4;
}
.cat-drawer-item:hover { background: rgba(255, 255, 255, 0.06); text-decoration: none; }
.cat-drawer-item.active {
  background: rgba(108, 140, 255, 0.14);
  color: var(--primary);
  font-weight: 600;
}
.cat-drawer-count {
  float: right;
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 2px;
}
/* 窄屏顶部横向 tab（仅窄屏显示；宽屏被 drawer 取代） */
.cat-tabs-row { display: none; }

/* 断点：<900px 时隐藏 drawer，改顶部横向 tab */
@media (max-width: 900px) {
  .cat-layout { display: block; }
  .cat-drawer { display: none; }
  .cat-tabs-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
}
@media (max-width: 640px) {
  .cat-tabs-row { gap: 4px; }
}

/* ── 统一上下文导航栏（替代 shelf-tabs + cat-drawer 的轻量栏）── */
.context-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 6px;
  margin-bottom: 20px;
  padding: 8px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.context-bar-divider {
  display: inline-block;
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}
/* 主 tab（内容类型：讨论区/短篇/长篇） */
.context-bar-tabs {
  display: flex;
  gap: 2px;
}
.context-bar-tab {
  display: inline-block;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sub);
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.context-bar-tab:hover {
  color: var(--text);
  background: rgba(255,255,255,0.06);
  text-decoration: none;
}
.context-bar-tab.active {
  color: var(--primary);
  background: rgba(108,140,255,0.12);
  font-weight: 600;
}
/* 排序链接 */
.context-bar-sort {
  display: flex;
  gap: 2px;
}
.context-bar-sort-link {
  display: inline-block;
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text-sub);
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.context-bar-sort-link:hover {
  color: var(--text);
  background: rgba(255,255,255,0.06);
  text-decoration: none;
}
.context-bar-sort-link.active {
  color: var(--primary);
  font-weight: 600;
}
@media (max-width: 640px) {
  .context-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding: 8px 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .context-bar::-webkit-scrollbar { display: none; }
}

/* 窄屏章节横向条：可横滑 */
@media (max-width: 900px) {
  .chapter-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
  }
  .chapter-tabs .serial-chapter-link { flex-shrink: 0; }
}

/* ── 首页信息流 ── */
.welcome-banner {
  background: linear-gradient(135deg, rgba(108, 140, 255, 0.12), rgba(108, 140, 255, 0.03));
  border: 1px solid rgba(108, 140, 255, 0.35);
  border-radius: var(--radius);
  padding: 28px 26px;
  margin-bottom: 24px;
}
.welcome-line { font-size: 24px; font-weight: 800; }
.welcome-user { color: var(--primary); }
.welcome-sub {
  margin-top: 10px;
  color: var(--text-sub);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.welcome-sep { color: var(--border); }
.feed-list { display: flex; flex-direction: column; gap: 10px; }
.feed-item {
  display: flex;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  transition: border-color 0.15s;
  color: var(--text);
}
.feed-item:hover { border-color: var(--primary); text-decoration: none; }
.feed-item-main { flex: 1; min-width: 0; }
.feed-item-type {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(108, 140, 255, 0.12);
  color: #9db4ff;
}
.feed-item-head { margin-bottom: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.feed-item-head .tag { font-size: 11px; }
.feed-item-title { font-size: 16px; font-weight: 600; line-height: 1.5; word-break: break-word; }
.feed-item-excerpt {
  color: var(--text-sub);
  font-size: 13px;
  margin-top: 6px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.feed-item-meta {
  color: var(--text-sub);
  font-size: 12px;
  margin-top: 8px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.feed-end { text-align: center; padding: 18px 0 6px; color: var(--text-sub); font-size: 13px; }

/* ── 收件箱 ── */
.inbox-list { display: flex; flex-direction: column; gap: 10px; }
.inbox-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
}
.inbox-item.unread { border-color: var(--primary); }
.inbox-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inbox-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  flex-shrink: 0;
}
.inbox-tag-system { background: rgba(108, 140, 255, 0.15); color: #9db4ff; }
.inbox-tag-reply { background: rgba(46, 160, 67, 0.15); color: #7ee787; }
.inbox-title { font-size: 15px; font-weight: 600; flex: 1; min-width: 0; word-break: break-word; }
.inbox-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #7ee787; flex-shrink: 0; /* 未读圆点固定绿色，不随主题主色变化 */
}
.inbox-body {
  font-size: 14px; line-height: 1.7;
  color: var(--text-sub); margin-top: 8px;
  word-break: break-word; white-space: pre-wrap;
}
.inbox-foot { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.inbox-time { font-size: 12px; color: var(--text-sub); flex: 1; }
.inbox-unread-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  margin-left: 10px;
  vertical-align: middle;
}

/* ── 审核模块切换 segmented（链接形式） ── */
.admin-module-switch {
  display: inline-flex;
  margin-bottom: 18px;
}
.admin-module-switch .seg-item {
  text-decoration: none;
  display: inline-block;
}
.admin-module-switch .seg-item:hover { color: var(--primary); }
.admin-module-switch .seg-item.active:hover { color: #fff; }

/* ── 管理导航：桌面横排 / 移动端左侧抽屉 ── */
/* 桌面「菜单」按钮隐藏 */
.admin-drawer-toggle { display: none; }
/* 抽屉与遮罩默认隐藏（仅移动端启用） */
.admin-drawer,
.admin-drawer-backdrop {
  display: none;
}

@media (max-width: 900px) {
  /* 桌面横向 segmented 隐藏，改用抽屉 */
  .admin-seg { display: none; }
  /* 菜单按钮显示 */
  .admin-drawer-toggle { display: inline-block; }

  /* 左侧抽屉：占半屏 */
  .admin-drawer {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 50%;
    max-width: 320px;
    height: 100vh;
    z-index: 5500;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    background: var(--card);
    border-right: 1px solid var(--border);
    box-shadow: 0 0 30px rgba(0,0,0,.3);
  }
  .admin-drawer.open { transform: translateX(0); }
  .admin-drawer-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
  }
  .admin-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
  }
  .admin-drawer-close {
    background: none;
    border: none;
    color: var(--text-sub);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
  }
  .admin-drawer-close:hover { color: var(--text); }
  .admin-drawer-nav {
    padding: 12px 8px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .admin-drawer-item {
    display: block;
    padding: 12px 14px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 15px;
  }
  .admin-drawer-item:hover { background: rgba(148,163,200,0.14); }
  .admin-drawer-item.active { background: var(--primary); color: #fff; }
  .admin-drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 5499;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease;
  }
  .admin-drawer-backdrop.show { opacity: 1; visibility: visible; }
}

/* ── 分页 ── */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.pager-current { color: var(--text-sub); font-size: 13px; }

/* ── 讨论区（短篇/长篇） ── */
.discussion {
  margin-top: 4px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.discussion-title { font-size: 18px; font-weight: 700; margin: 0; }
.discussion .qa-post-head { margin-bottom: 8px; }
.discussion-comments { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.discussion-comment {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.discussion-comment-content {
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap; /* 保留换行（纯文本评论） */
  word-break: break-word;
  color: var(--text);
}
.discussion-comment-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.discussion-replies {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  padding-left: 16px;
  border-left: 2px solid var(--border);
}
.discussion-reply { background: var(--card-soft); border-color: transparent; padding: 12px 16px; }
.reply-form { margin-top: 12px; }
.reply-form .form-input { min-height: 64px; }
.discussion-form { margin-top: 20px; }
.discussion-hint { color: var(--text-sub); font-size: 12px; margin-top: 8px; }

/* ── 响应式：窄屏布局修复 ── */

@media (max-width: 640px) {
  /* 页面容器与卡片：收窄内边距 */
  .page-wrap, .page-wrap-wide { padding: 20px 14px 48px; }
  .article-detail { padding: 22px 18px; }
  .qa-post { padding: 18px 16px; }
  .qa-answer { padding: 16px 16px; }
  .submission-card { padding: 16px 16px; }
  .auth-card { padding: 24px 18px; }
  .auth-wrap { padding: 36px 16px; }
  .profile-card { padding: 20px 16px; }
  .my-card { padding: 18px 16px; }
  .member-row { padding: 14px 14px; }
  .discussion-comment { padding: 14px 14px; }
  .discussion-reply { padding: 10px 12px; }
  .discussion-replies { padding-left: 10px; }

  /* 头部操作行：按钮堆叠右对齐，不再与标题抢位 */
  .page-head { align-items: flex-start; }
  .page-head-actions { width: 100%; justify-content: flex-end; }
  .page-title { font-size: 21px; }

  /* 工具栏与输入区 */
  .editor-toolbar { gap: 4px; padding: 8px; }
  .tool-size-select { min-width: 60px; }
  .editor-area { min-height: 320px; }
  .qa-editor-toolbar { flex-wrap: wrap; gap: 6px; }
  .qa-answer-form-wrap { margin-top: 18px; }

  /* 表单：一行多项改为竖直堆叠 */
  .form-row { flex-direction: column; align-items: stretch; }
  .docs-search { flex-direction: column; align-items: stretch; }
  .docs-search .btn { width: 100%; }
  .serial-edit-layout { flex-direction: column; }
  .serial-chapter-sidebar { width: 100%; }
  .serial-chapter-list { max-height: none; }
  .chapter-nav-bottom { gap: 10px; }

  /* 列表项 */
  .article-item .article-item-actions { width: 100%; justify-content: flex-end; }
  .member-actions { width: 100%; justify-content: flex-end; }
  .my-card-head { flex-wrap: wrap; gap: 8px; }
  .member-bottom { margin-top: 16px; }
  .qa-item { padding: 14px 14px; }
  .qa-item-excerpt { display: none; } /* 窄屏隐藏摘要，保持列表清爽 */

  /* 用户表：窄屏降级为卡片式两列 */
  .user-table-head { display: none; }
  .user-row { flex-wrap: wrap; padding: 12px 14px; gap: 6px 12px; }
  .user-col-name { flex: 1 1 100%; }
  .user-col-email { flex: 1 1 100%; }
  .user-col-role { flex: 0 0 auto; }
  .user-col-members, .user-col-date { flex: 0 0 auto; }

  /* 头像裁剪弹窗 */
  .crop-modal { padding: 18px 14px; max-width: calc(100vw - 24px); }
}

@media (max-width: 480px) {
  .btn { padding: 8px 14px; font-size: 13px; }
  .btn-sm { padding: 4px 10px; font-size: 12px; }
  .qa-action-btn { font-size: 12px; }
  .qa-post-actions { gap: 12px; }
  .discussion-comment-actions { gap: 10px; }
  .admin-module-switch { width: 100%; }
  .admin-module-switch .seg-item { flex: 1; text-align: center; }
  .serial-chapter-nav { gap: 4px; }
  .serial-chapter-link { padding: 5px 10px; font-size: 12px; }
  .crop-stage canvas { max-height: 50vh; }
  .report-reasons { gap: 8px 14px; }
  .settings-section-title { margin: 20px 0 12px; }
}

/* ── 隐私设置开关 ── */
.privacy-section { margin-top: 8px; }
.privacy-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.privacy-row:last-of-type { border-bottom: none; }
.privacy-info { flex: 1; min-width: 0; }
.privacy-title { display: block; font-size: 14px; font-weight: 600; color: var(--text); }
.privacy-hint { display: block; font-size: 12px; color: var(--text-sub); margin-top: 4px; line-height: 1.6; }
.switch {
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  height: 24px;
  margin-top: 2px;
}
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .switch-track {
  position: absolute;
  inset: 0;
  border-radius: 24px;
  background: rgba(148, 163, 200, 0.25);
  transition: background 0.2s;
  cursor: pointer;
}
.switch .switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }

/* ── 公开主页：子账号列表 / 主账号链接 ── */
.member-row-list { display: flex; flex-direction: column; gap: 10px; }
.member-row { text-decoration: none; color: var(--text); }
.member-row-name { font-size: 15px; font-weight: 600; flex: 0 0 auto; }
.member-row-bio {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text-sub);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-actions-public { border-top: none; margin-top: 0; padding-top: 0; justify-content: flex-start; }

/* ── 搜索结果中的用户头像 ── */
.article-item-avatar {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
}

/* ── 私聊页 ── */
.chat-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: stretch; }
.chat-side {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  position: relative;
}
.chat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  background: transparent;
  transition: background 0.15s;
  position: relative;
}
.chat-card:hover { background: rgba(148, 163, 200, 0.08); }
.chat-card.active { background: rgba(108, 140, 255, 0.12); }
.chat-card-main { flex: 1; min-width: 0; }
.chat-card-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-card-sub { color: var(--text-sub); font-weight: 400; }
.chat-card-last { font-size: 12px; color: var(--text-sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.chat-card-unread {
  flex: 0 0 auto;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  padding: 0 5px;
}
.chat-request {
  background: rgba(108, 140, 255, 0.07);
  border: 1px dashed rgba(108, 140, 255, 0.35);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.chat-request-info { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.chat-request-tag { font-size: 11px; background: rgba(108, 140, 255, 0.15); color: #9db4ff; border-radius: 999px; padding: 1px 8px; flex: 0 0 auto; }
.chat-request-name { font-weight: 600; font-size: 13px; }
.chat-request-actions { display: flex; gap: 6px; }
.chat-main {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 480px;
  max-height: calc(100vh - 220px);
}
.chat-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.chat-head-name { font-size: 16px; font-weight: 700; }
.chat-head-name:hover { color: var(--primary); }
.chat-state { font-size: 12px; color: var(--text-sub); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 68%; }
.chat-msg.mine { align-self: flex-end; align-items: flex-end; }
.chat-bubble {
  background: var(--card-soft);
  border: 1px solid var(--border);
  border-radius: 14px 14px 14px 4px;
  padding: 9px 13px;
  word-break: break-word;
  white-space: pre-wrap;
  width: fit-content;      /* 气泡宽度随内容收缩（最长不超过外层上限） */
  max-width: 100%;
}
.chat-msg.mine .chat-bubble { background: rgba(108, 140, 255, 0.18); border-color: rgba(108, 140, 255, 0.3); border-radius: 14px 14px 4px 14px; }
.chat-bubble-text { font-size: 14px; }
.chat-bubble-img { display: block; max-width: 260px; max-height: 260px; border-radius: 8px; cursor: pointer; }
.chat-msg-time { font-size: 11px; color: var(--text-sub); margin-top: 3px; }
.chat-composer {
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-composer.disabled { opacity: 0.55; }
/* 输入框：紧凑“单行”观感，随内容自动增高（最高 4 行） */
.chat-input {
  flex: 1;
  min-height: 38px;
  height: auto;
  resize: none;
  overflow-y: hidden;
  line-height: 20px;
  padding: 8px 12px;
}
.chat-img-btn { flex: 0 0 auto; }
.chat-placeholder { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-sub); }
.chat-empty { padding: 24px 10px; color: var(--text-sub); font-size: 13px; text-align: center; }
.chat-ctx {
  position: fixed;
  z-index: 99999;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
/* 显隐由 JS 同步控制 open 类与 hidden 属性；!important 兜底历史遗留的覆盖组合 */
.chat-ctx[hidden] { display: none !important; }
.chat-ctx.open { display: flex !important; }
.chat-ctx button {
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.chat-ctx button:hover { background: rgba(148, 163, 200, 0.12); }
.chat-ctx button.danger { color: var(--danger); }
.chat-ctx button.danger:hover { background: rgba(242, 85, 90, 0.12); }
.chat-apply-tip { display: none; }

/* ── 管理后台：用户操作 / 全局消息 ── */
.op-row .user-col-email { flex: 1.6; }
.op-row .user-col-members { flex: 1.2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.op-row .user-col-name { flex: 2.6; white-space: normal; overflow: visible; align-self: stretch; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.op-row .user-col-date { flex: 0 0 96px; }
.op-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.op-main { min-width: 0; }
.op-action { font-weight: 700; color: var(--text); }
.op-title { color: var(--text); word-break: break-word; }
.op-details { margin-top: 4px; }
.op-details summary { cursor: pointer; color: var(--primary); font-size: 13px; user-select: none; }
.op-detail-body {
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--card-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow-y: auto;
}
.op-btns { flex: 0 0 auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.msg-edit-form { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.msg-edit-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── 审核台：内容主体 / 跳转按钮 ── */
.audit-body-details { margin-top: 10px; }
.audit-body { max-height: 60vh; line-height: 1.8; }
.audit-body img { max-width: 100%; height: auto; }

/* ── 私聊页：移动端与主流即时通讯一致 ──
   窄屏为“列表/会话”两态：
   - 无会话(.chat-active 缺失)：全屏好友列表
   - 有会话(.chat-active)：全屏会话 + 会话头返回按钮
   导航高度按 64px 折算，其余交给内部 flex 滚动。 */
.chat-back { display: none; }

@media (max-width: 900px) {
  .chat-page-wrap { max-width: none; padding: 0; }
  .chat-page-wrap .page-head { display: none; }
  .chat-layout {
    display: block;
    height: calc(100dvh - 64px);
    max-height: none;
    border-radius: 0;
    border: none;
  }
  .chat-page-wrap:not(.chat-active) .chat-main { display: none; }
  .chat-page-wrap.chat-active .chat-side { display: none; }
  .chat-side {
    max-height: none;
    height: 100%;
    border: none;
    border-radius: 0;
  }
  .chat-main {
    height: 100%;
    max-height: none;
    border: none;
    border-radius: 0;
    min-height: 0;
  }
  .chat-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--card-soft);
    border: 1px solid var(--border);
    font-size: 24px;
    line-height: 1;
    text-decoration: none;
    color: var(--text);
    margin-right: 8px;
  }
  .chat-back:active { background: rgba(148, 163, 200, 0.2); }
  .chat-head-name { font-size: 15px; }
  .chat-composer { padding: 8px 10px; }
  .chat-msg { max-width: 82%; }
  .chat-page-wrap { height: calc(100dvh - 64px); }
  .chat-layout { flex: 1 1 auto; min-height: 0; }
}

/* ── 好友申请栏：折叠容器（防刷屏） ── */
.chat-requests {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(108, 140, 255, 0.05);
}
.chat-requests > summary {
  cursor: pointer;
  list-style: none;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
  user-select: none;
}
.chat-requests > summary::-webkit-details-marker { display: none; }
.chat-requests > summary::before { content: "▸ "; color: var(--primary); }
.chat-requests[open] > summary::before { content: "▾ "; }
.chat-requests[open] > summary { border-bottom: 1px solid var(--border); color: var(--text); }
.chat-request-items { padding: 8px; display: flex; flex-direction: column; gap: 8px; }

/* ── 私聊增强 ── */
/* 消息工具（悬停自己消息显示） */
.chat-msg-tools { display: none; gap: 8px; margin-top: 2px; }
.chat-msg:hover .chat-msg-tools, .chat-msg:active .chat-msg-tools { display: inline-flex; }
.chat-msg-tools button {
  font-size: 11px;
  background: none;
  border: none;
  color: var(--text-sub);
  cursor: pointer;
  padding: 0 2px;
}
.chat-msg-tools button:hover { color: var(--primary); }
.chat-msg-tools button[data-del]:hover { color: var(--danger); }
/* 置顶好友卡片 */
.chat-card.pinned { box-shadow: inset 2px 0 0 var(--primary); }
.chat-card.pinned .chat-card-name::before { content: "📌 "; font-size: 11px; }

/* ── 私聊页：整体高度撑满可用视口（消息多/少都不塌） ── */
@media (min-width: 901px) {
  .chat-page-wrap {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 64px);
    box-sizing: border-box;
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 20px 12px;
  }
  .chat-page-wrap .page-head { flex: 0 0 auto; margin-bottom: 12px; padding-top: 0; }
  .chat-layout {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 16px;
    align-items: stretch;
    overflow: hidden;
  }
  .chat-side { min-height: 0; max-height: none; height: auto; }
  .chat-main { min-height: 0; max-height: none; height: auto; }
  .chat-msgs { flex: 1 1 auto; min-height: 0; }
  .chat-composer { flex: 0 0 auto; }
}

/* ── 撤回提示：聊天框居中小灰字（非气泡） ── */
.chat-msg.revoked {
  align-items: center;
  max-width: 100%;
  margin: 3px 0;
}
.chat-msg.revoked .chat-msg-time { display: none; }   /* 提示行不带时间 */
.chat-revoked-text {
  color: var(--text-sub);
  font-size: 12px;
  text-align: center;
  user-select: none;
}
.chat-revoked-text.mine-edit {
  color: var(--text-sub);
  cursor: pointer;
  text-decoration: underline dotted;
}
.chat-revoked-text.mine-edit:hover { color: var(--primary); }

/* ── 好友卡片的显式更多按钮（右键之外的最可靠入口） ── */
.chat-card-more {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  line-height: 1;
  border: none;
  background: none;
  color: var(--text-sub);
  font-size: 16px;
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  display: none;
}
.chat-card:hover .chat-card-more,
.chat-card.active .chat-card-more,
.chat-card-more:focus { display: block; }
.chat-card-more:hover { background: rgba(148, 163, 200, 0.18); color: var(--text); }
/* 移动端：卡片行自带 ⋯（避免长按依赖） */
@media (hover: none) {
  .chat-card-more { display: block; }
}

/* ── 书架：发布状态徽章 ── */
.pub-badge {
  display: inline-block;
  vertical-align: middle;
  font-size: 11px;
  line-height: 1;
  padding: 3px 8px;
  border-radius: 999px;
  margin-left: 8px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.pub-badge-on {
  background: rgba(46, 204, 113, 0.15);
  color: #2ecc71;
  border: 1px solid rgba(46, 204, 113, 0.4);
}
.pub-badge-off {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-sub);
  border: 1px solid rgba(148, 163, 184, 0.35);
}

/* ── 书架：⋯ 菜单 ── */
.card-menu { position: relative; display: inline-block; }
.card-menu-btn {
  width: 30px;
  height: 30px;
  line-height: 1;
  border: none;
  background: none;
  color: var(--text-sub);
  font-size: 18px;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}
.card-menu-btn:hover { background: rgba(148, 163, 200, 0.18); color: var(--text); }
.card-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 150px;
  background: var(--card);
  border: 1px solid var(--border, rgba(148, 163, 184, 0.25));
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 5px;
  z-index: 60;
}
.card-menu-dropdown form { margin: 0; }
.card-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s;
}
.card-menu-item:hover { background: rgba(148, 163, 200, 0.14); }
.card-menu-item-danger { color: #ff4d4f; }
.card-menu-item-danger:hover { background: rgba(255, 77, 79, 0.12); }

/* ── 站外链接安全提醒页（/out）：四行居中 ── */
.out-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 14vh 20px 60px;
  text-align: center;
}
.out-head {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 14px;
}
.out-url {
  display: inline-block;
  max-width: 100%;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-sub);
  background: var(--card-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  margin: 0 0 16px;
  word-break: break-all;
}
.out-tip {
  font-size: 14px;
  color: var(--text-sub);
  margin: 0;
}
.out-actions {
  margin: 26px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
}
.out-go {
  font-size: 16px;
  font-weight: 600;
  color: var(--danger);
  text-decoration: none;
  padding: 8px 26px;
  border: 1px solid var(--danger);
  border-radius: 999px;
  transition: background 0.15s;
}
.out-go:hover {
  background: rgba(242, 85, 90, 0.1);
  text-decoration: none;
}
.out-cancel {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 12px;
}
.out-cancel:hover { opacity: 0.72; }
