/* 高度基准用百分比：相对初始包含块，不经过 vh/dvh（部分内核实现有误，实测偏差 110px） */
html { height: 100%; }
/* 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;
  /* 实心按钮底色：与 --primary 分开，保证白字 ≥4.5:1（见 app/theme.py） */
  --primary-solid: #5771ce;
  --primary-solid-hover: #4c63b5;
  --danger: #f2555a;
  --danger-hover: #e04045;
  --danger-solid: #cd484c;
  --danger-solid-hover: #b43f42;
  --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; }
/* 浏览器默认 placeholder 色（#757575）在暗色输入底仅 3.75、在浅色输入底 4.26；
   跟次要文字同色即可达标，且各主题自动生效 */
::placeholder { color: var(--text-sub); opacity: 1; }
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-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-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-solid);
  color: #fff;
}
.nav-link-solid:hover { background: var(--primary-solid-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-solid);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  margin-left: 5px;
  vertical-align: 1px;
  box-sizing: border-box;
}
/* ── 管理行（横向 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;
}

/* 技术服务方署名 */
.site-footer-credit {
  display: block;
  font-size: 12px;
}

.site-footer-credit a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-footer-credit a:hover {
  color: var(--text-sub);
  text-decoration-thickness: 2px;
}

/* ── 按钮 ── */
.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-solid); color: #fff; }
.btn-primary:hover { background: var(--primary-solid-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-solid); border-color: var(--danger-solid); color: #fff; }
.btn-danger-solid:hover { background: var(--danger-solid-hover); border-color: var(--danger-solid-hover); }
.btn-warning { background: #f5a623; border-color: #f5a623; color: #3a2a00; }
.btn-warning:hover { background: #e0951a; border-color: #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 { 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; }
/* 链接夹在正文里时必须有不依赖颜色的线索（1.4.1）：这两个位置的链接
   与周围 text-sub 文字亮度几乎相同，只靠颜色完全分辨不出 */
.auth-switch a, .qa-login-hint a { text-decoration: underline; text-underline-offset: 2px; }

/* ── 注册子账号 ── */
.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; }
.auth-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 { width: 70%; max-width: 1024px; margin: 0 auto; padding: 32px 20px 60px; }
.page-wrap-wide { width: 55%; 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: 56px; height: 56px; font-size: 22px; }
.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-solid);
  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: 999px) {
  .profile-head { gap: 12px; }
  .profile-head-avatar .avatar { width: 44px; height: 44px; font-size: 18px; }
}
/* 名称/简介行：内容居左、灰色「修改」字居卡片右侧，同行 */
.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-add {
  width: 100%;
  font: inherit;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.member-add:hover { border-color: var(--primary); background: var(--card-soft); }
.member-add:active { transform: translateY(1px); }
.member-add-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  color: var(--text-sub);
  transition: border-color 0.15s, color 0.15s;
}
.member-add:hover .member-add-icon { border-color: var(--primary); color: var(--primary); }

/* ── 头像裁剪弹窗 ── */
.crop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  /* 移动端键盘弹出时可视高度只剩 200~300px，模态框会高于视口。
     没有 padding + overflow 时，align-items:center 会把内容顶到负坐标，
     且 overlay 滚不动 → 标题和保存按钮永远看不到。
     padding 给个上边距，配合 overflow:auto 保证任何高度都能滚到。 */
  padding: 16px;
  overflow-y: auto;
}
.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);
  /* 用 margin:auto 替代父级 align-items:center：
     前者在内容超出容器时不会产生「顶部被裁且滚不到」的 flexbox 陷阱。 */
  margin: auto;
  flex-shrink: 0;
}
.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;
  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-strikethrough { text-decoration: line-through; }
.tool-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.toolbar-spacer { flex: 1; }
/* ── 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%;
  height: 100%;
  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%;
  height: 100%;
  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);
  /* 选项过多时单行横向滚动，不换行、不撑破；滚动条隐藏 */
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.shelf-tabs::-webkit-scrollbar { display: none; }
.shelf-tab {
  display: inline-block;
  flex: 0 0 auto;
  white-space: nowrap;
  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 { position: relative; max-width: 800px; margin: 16px auto 0; }
.serial-chapter-sidebar {
  width: 205px;
  position: absolute;
  right: 100%;
  margin-right: 16px;
  top: 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 { width: 100%; }
.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-handle {
  flex-shrink: 0;
  width: 11px;
  height: 16px;
  margin-left: 8px;
  cursor: grab;
  background-image: linear-gradient(var(--text-sub) 1px, transparent 1px);
  background-size: 100% 5px;
  background-position: 0 2px;
  opacity: .6;
  touch-action: none;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}
.serial-chapter-item.dragging { opacity: .45; }

/* 导入页文件列表：拖拽手柄 + 当前转换/拖拽状态 */
.file-drag-handle {
  flex-shrink: 0;
  width: 11px;
  height: 16px;
  cursor: grab;
  background-image: linear-gradient(var(--text-sub, #bbb) 1px, transparent 1px);
  background-size: 100% 5px;
  background-position: 0 2px;
  opacity: .6;
  touch-action: none;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}
.file-row.active { outline: 2px solid var(--primary); outline-offset: -1px; }
.file-row.dragging { opacity: .45; }

/* 触屏：放大拖拽手柄的触控热区（视觉线条宽度不变） */
@media (pointer: coarse) {
  .serial-chapter-handle,
  .file-drag-handle {
    width: 30px;
    height: 22px;
    margin-left: 2px;
    background-size: 11px 5px;
    background-repeat: repeat-y;
    background-position: center 3px;
  }
}

/* ── 长篇阅读章节导航 ── */
.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;
  margin: 0;
  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-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: 999px) {
  /* 移动端导航：品牌一行，搜索框第二行整宽，导航菜单第三行 */
  .nav-inner {
    flex-direction: column;
    justify-content: center;
    height: auto;
    padding: 8px 14px 10px;
    gap: 6px;
  }
  .nav-brand { font-size: 16px; }
  .nav-links {
    margin-left: auto;
    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; padding: 14px 14px; }
}

/* ── 主题设置页 ── */
.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; }
.settings-section-subtitle { font-size: 14px; font-weight: 700; margin: 18px 0 10px; }
.settings-warn-block {
  margin-top: 18px;
  padding: 12px 16px;
  border: 1px solid rgba(229, 72, 77, 0.35);
  border-radius: calc(var(--radius) - 2px);
  background: rgba(229, 72, 77, 0.06);
}
.text-danger { color: #e5484d; }
.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;
}
.custom-color-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.custom-color-hex { width: 110px; font-family: monospace; text-transform: lowercase; }
.hsl-sliders { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; max-width: 440px; }
.hsl-row { display: flex; align-items: center; gap: 10px; }
.hsl-label { width: 48px; font-size: 12px; color: var(--text-sub); }
.hsl-val { width: 42px; text-align: right; font-size: 12px; color: var(--text-sub); font-variant-numeric: tabular-nums; }
.hsl-range {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 10px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--track, var(--card-soft));
  cursor: pointer;
}
.hsl-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  cursor: grab;
}
.hsl-range::-moz-range-track { height: 10px; border-radius: 5px; background: var(--track, var(--card-soft)); }
.hsl-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  cursor: grab;
}
.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-solid); 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: 12px; }
.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; margin-top: 14px; }
/* ── 管理操作红色确认 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;
  /* 矮视口（横屏/小窗）下 modal 可能高于视口，无 padding+overflow
     会被裁且滚不动，见 .crop-overlay 的注释。 */
  padding: 16px;
  overflow-y: auto;
}
.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);
  margin: auto;
  flex-shrink: 0;
}
.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; }
.user-col-op { flex: 0 0 70px; text-align: right; }

/* ── 管理后台：审计日志 ── */
.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: #3a2a00;
  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: 999px) {
  .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: 999px) {
  .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); }
/* 搜索落地页欢迎卡：紧凑小条，不挤占推荐内容 */
.search-landing .welcome-banner {
  padding: 12px 18px;
  margin: 0 auto 16px;
  width: min(560px, 100%);
}
.search-landing .welcome-line { font-size: 17px; }
.search-landing .welcome-sub { margin-top: 6px; font-size: 13px; }
.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-item-img {
  display: block;
  margin-top: 10px;
  max-width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: calc(var(--radius) - 2px);
  background: rgba(255,255,255,0.04);
}
.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-solid); 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: 999px) {
  /* 页面容器与卡片：收窄内边距 */
  .page-wrap, .page-wrap-wide { padding: 20px 14px 48px; width: auto; max-width: 100%; }
  .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; }
  .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; }
  .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 { max-width: 100%; margin-left: 0; margin-right: 0; }
  .serial-chapter-sidebar { position: static; width: 100%; margin-bottom: 12px; }
  .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; }
  .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: 18px; 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-ai-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  font-size: 10px;
  font-weight: 700;
  line-height: 15px;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 999px;
  vertical-align: middle;
}

/* ── AI 会话：配额进度条（在会话面板标题下方） ── */
.ai-quota {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  padding: 0 2px;
  flex-shrink: 0;
}
.ai-quota-track {
  flex: 1;
  height: 10px;
  background: var(--card-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.ai-quota-fill {
  height: 100%;
  width: 0;
  min-width: 2px;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.ai-quota-fill.low { background: var(--danger); }
.ai-quota-text {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-sub);
  white-space: nowrap;
}

/* ── AI 会话：流式回复（思考 / 工具调用 / 正文） ── */
.chat-ai-live { align-items: flex-start; }
.chat-ai-live-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-sub);
}
.chat-ai-live-body { display: flex; flex-direction: column; gap: 6px; max-width: 100%; }
.chat-ai-think {
  max-width: 100%;
  font-size: 12px;
  color: var(--text-sub);
  background: var(--card-soft);
  border-left: 2px solid var(--border);
  padding: 6px 10px;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  opacity: 0.85;
}
.chat-ai-tool {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: var(--text-sub);
  min-width: 0;            /* 允许这一行收缩，否则下面那个 nowrap 参数会撑破父级 */
  max-width: 100%;
}
.chat-ai-tool-name {
  font-weight: 600;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 999px;
  padding: 1px 8px;
  flex-shrink: 0;
}
.chat-ai-tool-args {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--text-sub);
  /* 这里是「展开后给人看」的过程详情，必须看全 —— 不做省略号、不做截断，
     长 JSON 靠 anywhere 换行。宽度由父级 max-width 链约束，不会再撑破。 */
  max-width: 100%;
  min-width: 0;
  flex: 0 1 auto;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
}
.chat-ai-tool-result {
  font-size: 12px;
  color: var(--text-sub);
  background: var(--card-soft);
  border-radius: 6px;
  padding: 5px 10px;
  overflow-wrap: anywhere;  /* 工具结果里常有长 URL / 无空格 JSON */
  word-break: break-word;
  min-width: 0;
  max-width: 100%;
}
.chat-ai-process {
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-sub);
  /* 消息列是 align-items:flex-start（子块按 fit-content 定宽），不加这条时
     内部的 nowrap 内容会把 min-content 顶到上千像素，整块溢出出滚动条 */
  max-width: 100%;
  min-width: 0;
}
.chat-ai-process > summary {
  cursor: pointer;
  user-select: none;
  color: var(--text-sub);
  font-size: 12px;
  padding: 2px 0;
}
.chat-ai-process > summary:hover { color: var(--text); }
.chat-ai-process-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  min-width: 0;
  max-width: 100%;
}
.chat-ai-out {
  max-width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── AI 会话面板：会话框内的遮罩浮层，从左向右展开 ── */
.ai-mask {
  position: absolute;
  inset: 0;
  z-index: 11;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0s 0.2s;
}
.ai-mask.show {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease;
}
.ai-sessions-panel {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 12;
  width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: flex-end;   /* 内容右对齐：宽度 0→260 时自右向左滑出 */
  transition: width 0.22s ease;
}
.ai-sessions-panel.open {
  width: 260px;
  box-shadow: -2px 0 16px rgba(0, 0, 0, 0.22);
}
.ai-sessions-inner {
  width: 260px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--card);
  overflow-y: auto;
}
.ai-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
.ai-drawer-close {
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  font-family: inherit;
}
.ai-drawer-close:hover { color: var(--text); }
.ai-drawer-new { padding: 12px 12px 6px; flex-shrink: 0; }
.ai-session-new {
  width: 100%;
  padding: 9px 12px;
  border: 1px dashed var(--primary);
  border-radius: 8px;
  background: none;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.ai-session-new:hover { background: rgba(108, 140, 255, 0.1); }
.ai-session-list { flex: 1; overflow-y: auto; padding: 6px 8px 16px; }
.ai-session-item { display: flex; align-items: center; border-radius: 8px; }
.ai-session-item:hover { background: var(--card-soft); }
.ai-session-item.active { background: rgba(108, 140, 255, 0.12); }
.ai-session-link {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 10px;
  color: var(--text);
  font-size: 13px;
}
.ai-session-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-session-time { font-size: 11px; color: var(--text-sub); }
.ai-session-del-form { flex-shrink: 0; }
.ai-session-del {
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 12px;
  padding: 6px 10px;
  cursor: pointer;
  font-family: inherit;
}
.ai-session-del:hover { color: var(--danger); }
.ai-session-empty { padding: 20px; text-align: center; color: var(--text-sub); font-size: 13px; }
.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-solid);
  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);
  overflow: hidden;
  position: relative;
}
.chat-main-body {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.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-head-btn {
  margin-left: auto;
  align-self: center;
  flex: 0 0 auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-sub);
  font-size: 18px;
  line-height: 1;
  padding: 4px 10px;
  cursor: pointer;
  font-family: inherit;
}
.chat-head-btn:hover { color: var(--text); background: var(--card-soft); }
.chat-state { font-size: 12px; color: var(--text-sub); }
/* 消息区（滚动条跟随主题色） */
.chat-msgs {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) transparent;
}
.chat-msgs::-webkit-scrollbar { width: 8px; }
.chat-msgs::-webkit-scrollbar-track { background: transparent; }
.chat-msgs::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.chat-msgs::-webkit-scrollbar-thumb:hover {
  background: var(--primary-hover);
  border: 2px solid transparent;
  background-clip: padding-box;
}
.chat-msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 68%; min-width: 0; }
.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; }
/* 按钮与输入框等高对齐：输入框 min-height 38px（单行），故按钮也 38px。
   输入框多行时按钮保持 38px 底部对齐（同主流 IM）。 */
.chat-composer .btn {
  height: 38px;
  padding-top: 0;
  padding-bottom: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
/* 流式期间「发送」切换成的「停止」按钮 */
.chat-composer .btn.chat-stop-btn {
  background: var(--danger-solid);
  border-color: var(--danger-solid);
  color: #fff;
}
.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 属性；[hidden] 特异性高于基类，无需 !important */
.chat-ctx[hidden] { display: none; }
.chat-ctx.open { display: flex; }
.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); }

/* ── 管理后台：用户操作 / 全局消息 ── */
.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; padding: 2px 0; }
.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;
}

/* 举报详情表（审核台）：举报人 / 时间 / 完整理由 */
.report-detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: normal;
}

/* 详情表不需要 .op-detail-body 的 pre-wrap 与 260px 最小高度 */
.op-detail-body.report-detail-wrap {
  white-space: normal;
  max-height: none;
  padding: 4px 12px;
}

.report-detail-table th,
.report-detail-table td {
  text-align: left;
  vertical-align: top;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}

.report-detail-table th {
  color: var(--text-sub);
  font-weight: 500;
  white-space: nowrap;
}

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

.report-detail-time {
  white-space: nowrap;
  color: var(--text-sub);
}

.report-detail-note {
  margin-top: 4px;
  color: var(--text-sub);
  font-size: 12px;
}
.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; }
/* 审核台：原始 Markdown 折叠块（等宽显示，长行不撑破卡片） */
.audit-source {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  max-height: 40vh;
  white-space: pre-wrap;
}
.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 { width: 100%; max-width: none; padding: 0; margin: 0; }
  .chat-page-wrap .page-head { display: none; }
  .chat-layout {
    display: block;
    max-height: none;
    border-radius: 0;
    border: none;
    flex: 1 1 auto;
    min-height: 0;
  }
  .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;
  }
  /* AI 会话面板：窄屏浮层占更宽 */
  .ai-sessions-panel.open { width: 78%; }
  .ai-sessions-inner { width: 78vw; }
  .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-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;
    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); }
/* 菜单项当链接用时去掉下划线，视觉与按钮项一致 */
a.card-menu-item, a.card-menu-item:hover { text-decoration: none; }
.card-menu-sep {
  height: 1px;
  margin: 5px 8px;
  background: var(--border, rgba(148, 163, 184, 0.25));
}
/* 页面标题旁的状态标签（已收录为文档 等） */
.page-title .pub-badge { margin-left: 8px; vertical-align: middle; }

/* ── 站外链接安全提醒页（/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;
  text-decoration: none;
}
.out-cancel:hover { opacity: 0.72; }

/* ── 404 错误页 ── */
.nf-hero {
  text-align: center;
  padding: 40px 0 8px;
}
.search-hero {
  padding: 12px 0 4px;
}
/* 搜索页首次进入/空结果：整页垂直居中 */
.search-landing {
  display: flex;
  flex-direction: column;
}
.search-landing .search-hero {
  min-height: 52vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 0 16px;
}
.search-brand {
  font-size: 44px;
  font-weight: 800;
  line-height: 1.1;
  margin: 0 0 40px;
  font-family: Georgia, 'Times New Roman', 'Songti SC', 'SimSun', serif;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.search-brand-sub {
  display: block;
  margin-top: 10px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-sub);
}
.feed-title { text-align: center; margin-top: 8px; }
/* 搜索历史：普通文字居中排列 + 单条删除 */
.search-history {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  max-width: 100%;
}
.search-history-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px 6px;
  max-width: 640px;
}
.search-history-tag {
  color: var(--text-sub);
  font-size: 13px;
  text-decoration: none;
  transition: color 0.15s;
}
.search-history-tag:hover {
  color: var(--primary);
  text-decoration: underline;
}
.search-history-del {
  color: var(--text-sub);
  opacity: 0.45;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s, color 0.15s;
}
.search-history-del:hover {
  opacity: 1;
  color: var(--primary);
}
/* 搜索页 tabs：一级内容分类（segmented）+ 二级分类（shelf-tabs 下划线） */
.search-seg { margin: 4px 0 14px; }
.search-seg .seg-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.seg-count {
  font-size: 11px;
  font-weight: 700;
  background: rgba(108, 140, 255, 0.18);
  color: #9db4ff;
  border-radius: 999px;
  padding: 0 8px;
  line-height: 16px;
}
.seg-item.active .seg-count {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}
.search-subtabs { flex-wrap: nowrap; }
.search-subtabs .shelf-tab { padding: 8px 16px; }
.shelf-tab-count {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-sub);
  background: var(--card-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 7px;
  line-height: 16px;
}
.shelf-tab.active .shelf-tab-count {
  color: var(--primary);
  border-color: var(--primary);
}
@media (max-width: 999px) {
  .search-seg { display: flex; width: 100%; }
  .search-seg .seg-item { flex: 1; justify-content: center; padding: 7px 8px; }
}

/* 搜索页底部：问问 AI 引导卡片 */
.ai-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 28px 0 8px;
  padding: 18px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-sub);
  font-size: 14px;
}
.ai-cta-link {
  color: var(--primary);
  font-weight: 600;
}
.ai-cta-link:hover { text-decoration: underline; }
/* 搜索结果分页器 */
.search-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 20px 0 8px;
}
.search-pager-info { font-size: 13px; color: var(--text-sub); }
.nf-code {
  font-size: 64px;
  font-weight: 800;
  line-height: 1.1;
  margin: 0 0 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.nf-hint {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-sub);
  margin: 0 0 20px;
}
.nf-search {
  display: flex;
  gap: 0;
  justify-content: center;
  width: 100%;
  max-width: 640px;
  margin: 0 auto 8px;
}
.nf-search .nav-search-input {
  flex: 1;
  min-width: 0;
}
.nf-search-btn {
  background: var(--primary-solid);
  color: #fff;
  border: 1px solid var(--primary-solid);
  border-left: none;
  border-radius: 0 999px 999px 0;
  padding: 8px 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.nf-search-btn:hover { opacity: 0.88; }
.nf-other {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-sub);
  margin: 28px 0 16px;
}

/* ── 导入页：分屏容器与面板（base；原内联样式迁入此处） ── */
.import-split { display: none; gap: 16px; align-items: flex-start; }
#splitTabs { display: none; width: 100%; margin-bottom: 4px; }
#paneSrc, #paneMd {
  flex: 1;
  min-width: 0;
  background: var(--card, #fff);
  border: 1px solid var(--border, #eee);
  border-radius: 12px;
  overflow: hidden;
}
#paneMd { display: flex; flex-direction: column; }

/* ── 导入页：分屏 tabs（移动端） ── */
@media (max-width: 999px) {
  .import-split { flex-wrap: wrap; }
  #splitTabs { display: flex; }
  #paneSrc, #paneMd { flex: 1 1 100%; }
  .split-tab.active { background: var(--card,#fff); color: var(--text,#222); font-weight: 600; }
  .split-tab:not(.active) { color: var(--text-sub,#888); }
}

/* ── 导入页：分章弹窗的可点击行与分割条（点击反馈） ── */
.imp-line { position: relative; padding: 4px 6px; border-radius: 6px; cursor: pointer; transition: background 0.12s; }
.imp-line:hover { background: var(--card-soft); }
.imp-line:active { background: var(--border); }
.imp-split {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  padding: 6px 10px;
  background: rgba(108, 140, 255, 0.12);
  border-radius: 6px;
  font-size: 13px;
  color: var(--primary, #6c8cff);
  font-weight: 600;
}
.imp-split-x { background: none; border: none; color: var(--danger, #e5484d); cursor: pointer; font-size: 12px; margin-left: auto; }
.imp-split-x:hover { text-decoration: underline; }
.imp-line.is-flash, .imp-split.is-flash { animation: imp-flash 0.9s ease-out; }
@keyframes imp-flash {
  0% { box-shadow: 0 0 0 3px var(--primary, #6c8cff); }
  100% { box-shadow: 0 0 0 3px transparent; }
}

/* ── 设置页：账号安全 ── */
.settings-security-form { max-width: 420px; }
.settings-security-form .form-field { margin-bottom: 12px; }
.settings-danger-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.settings-danger-row .privacy-info { display: flex; flex-direction: column; gap: 4px; }

/* ── 聊天页：整屏应用式布局（单一来源，勿再散落补丁） ──
   三条踩过的坑，都写在这里，避免以后再往别处加：
   1. 高度别用 vh/dvh：移动端 100vh = URL 栏隐藏时的高度（比可视区高几十像素），
      部分内核的 dvh 实现也是错的（实测某浏览器 dvh=763 而可视区 653）→ 页面多出 110px 可滚。
      统一用百分比：html{height:100%} + body{height:100%}，各内核取值都对。
   2. body 有全局 min-height:100vh（页脚贴底套路），min-height 优先级高于 height，
      必须显式 min-height:0，否则上面第 1 条的修复会被它压住。
   3. flex 子项的 min-width/min-height 默认 auto（= 内容最小尺寸），列向容器里同样生效；
      内部 nowrap 文本（好友列表摘要）会把整页撑到几千像素宽 → 逐层显式归零。
   页面本身不可滚动：滚动只发生在 .chat-msgs 内部。 */
body.chat-mode {
  height: 100%;
  min-height: 0;      /* 坑 2 */
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body.chat-mode .site-nav { position: static; }   /* 页面不滚动，粘性导航毫无用处，还会盖住标题 */
body.chat-mode .site-main {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;       /* 坑 3 */
  display: flex;
  flex-direction: column;
}
body.chat-mode .chat-page-wrap {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;       /* 坑 3 */
  max-width: 100%;    /* 坑 3：不加这条，列表页摘要能把整页撑到 3517px */
  height: auto;
  max-height: none;
}
body.chat-mode .chat-layout {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  height: auto;
  max-height: none;
}
body.chat-mode .chat-side,
body.chat-mode .chat-main { min-height: 0; min-width: 0; max-height: none; }
body.chat-mode .chat-msgs { min-height: 0; }

/* ── 无障碍：跳过导航链接 / 焦点可见 / 灯箱关闭按钮复位 ── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100000;
  padding: 8px 16px;
  background: var(--primary-solid);
  color: #fff;
  border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }
button.img-modal-close { background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ── 浅色主题配色对比度修正（原硬编码状态色为深色底设计，浅色下对比度不足） ── */
.light-mode .tag-ok { color: #1b7f3b; }
.light-mode .tag-pending,
.light-mode .tag-warning { color: #8a5a00; }
.light-mode .tag-reject,
.light-mode .form-error { color: #b3261e; }
.light-mode .form-success { color: #1b7f3b; }
.light-mode .tag-main,
.light-mode .inbox-tag-system,
.light-mode .chat-request-tag,
.light-mode .feed-item-type { color: #3b5bdb; }
.light-mode .tag-current,
.light-mode .tag-ok,
.light-mode .inbox-tag-reply { color: #1b7f3b; }
.light-mode .pub-badge-on { color: #1b7f3b; }
.light-mode .seg-count { color: #3452cf; }
/* 选中项背景带浅蓝底，主色文字压在上面差 0.05，浅色主题改用正文色 */
.light-mode .cat-drawer-item.active { color: var(--text); font-weight: 600; }

/* 仅屏幕阅读器可见（用于给结果页补 h1 等） */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ── 页面加载进度条（整页导航期间显示） ── */
.page-loader {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 99999;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0s 0.2s;
}
.page-loader.show { opacity: 1; visibility: visible; transition: opacity 0.2s ease; }
.page-loader::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 35%;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
  transform: translateX(-100%);
  animation: page-loader-slide 1.1s ease-in-out infinite;
}
@keyframes page-loader-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(320%); }
}
@media (prefers-reduced-motion: reduce) {
  .page-loader::after { animation-duration: 2.4s; }
}

/* ── 通用对话框（替代原生 confirm/prompt） ── */
.dlg-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100001;
  padding: 20px;
  /* tulpaPrompt 带输入框，移动端会弹键盘 → 可视高度骤降，
     必须可滚，否则标题/按钮被裁。见 .crop-overlay 的注释。 */
  overflow-y: auto;
}
.dlg-overlay[hidden] { display: none; }
.dlg-modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  width: 420px;
  max-width: calc(100vw - 40px);
  box-shadow: var(--shadow);
  margin: auto;
  flex-shrink: 0;
}
.dlg-title { font-size: 17px; font-weight: 700; margin-bottom: 10px; }
.dlg-message { font-size: 14px; line-height: 1.7; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.dlg-input { margin-top: 12px; }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

/* AI 会话项：重命名按钮（与删除并排） */
.ai-session-rename {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 12px;
  padding: 6px 10px;
  cursor: pointer;
  font-family: inherit;
}
.ai-session-rename:hover { color: var(--primary); }

/* ── 分享按钮 + popover ──
   分享出去的必须是**公开地址**（/plaza/... 等），不是当前预览页地址；
   地址由后端 app/share.py 算好，通过 data-share-url 传入。
   链接可见（而非点了直接复制）：手机部分内核拿不到 clipboard 权限，
   把 URL 显示出来用户还能长按手动复制。 */
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-sub);
  font-size: 13px;
  font-family: inherit;
  padding: 7px 12px;
  cursor: pointer;
}
.share-btn:hover { color: var(--primary); border-color: var(--primary); }
.share-icon { flex-shrink: 0; }

.share-pop {
  position: fixed;
  z-index: 100002;   /* 高于 dlg-overlay(100001)，避免被其它弹窗盖住 */
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  width: min(340px, calc(100vw - 24px));
}
.share-pop-label { font-size: 12px; color: var(--text-sub); margin-bottom: 8px; }
.share-pop-row { display: flex; gap: 8px; align-items: center; }
.share-pop-url {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-soft);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 8px 10px;
}
.share-pop-copy { flex-shrink: 0; }

/* 选章节弹窗里的章节列表 */
.share-chapter-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 46vh;
  overflow-y: auto;
  margin-bottom: 16px;
}
.share-chapter-item {
  text-align: left;
  background: var(--card-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  padding: 10px 12px;
  cursor: pointer;
}
.share-chapter-item:hover { border-color: var(--primary); color: var(--primary); }
