/* ===== Quote Card (enhanced reply display) ===== */
.quote-card{
  border-left:3px solid rgba(96,165,250,.5);
  background:rgba(96,165,250,.04);
  border-radius:0 8px 8px 0;
  padding:8px 12px;
  margin-bottom:8px;
  font-size:13px;
  color:var(--text);
  opacity:.85;
}
.quote-card-author{
  font-weight:600;
  font-size:12px;
  color:#3b82f6;
  margin-bottom:2px;
}
.quote-card-text{
  overflow:hidden;
  display:-webkit-box;
  -webkit-line-clamp:3;
  -webkit-box-orient:vertical;
  line-height:1.45;
}

/* Sidebar user layout：让旧结构也能正常展示 */
.sidebar-user{ display:flex; align-items:center; gap:10px; margin-bottom:12px; padding-bottom:12px; border-bottom:1px solid rgba(255,255,255,.08); }
.sidebar-user-meta{ display:flex; flex-direction:column; line-height:1.1; }
.sidebar-user-name{ font-weight:700; }
.sidebar-user-actions{ margin-top:6px; display:flex; gap:8px; flex-wrap:wrap; }

/* Preset picker (profile avatar settings) */
.avatar-grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, var(--av-lg));
  gap:16px;
  justify-content:center;
  align-items:center;
  width:100%;
  margin-top:12px;
}
.avatar-choice-form{ margin:0; }
.avatar-choice{
  width:var(--av-lg);
  height:var(--av-lg);
  padding:0;
  border-radius:var(--av-radius-lg);
  overflow:hidden;
  border:1px solid var(--av-bd);
  background:transparent;
  cursor:pointer;
  box-shadow:0 0 0 3px var(--av-ring);
  transition: transform .12s ease, filter .12s ease;
}
.avatar-choice:hover{ transform: translateY(-1px); filter: brightness(1.08); }
.avatar-choice img{
  width:100%;
  height:100%;
  object-fit:cover;
  object-position:center;
  display:block;
  transform: scale(var(--preset-scale));
}

/* ===== 编辑器工具栏 — 毛玻璃 + 渐变交互 ===== */
.richbar {
    display: flex !important;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px;
    min-height: 56px;

    background: linear-gradient(135deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.02) 100%);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 14px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 2px 12px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.06);

    position: relative;
    z-index: 5;
}

/* 分隔符：在引用和链接之间、表格和表情之间加视觉分组 */
.richbtn[data-act="quote"]::after,
.richbtn[data-act="table"]::after {
    content: '';
    position: absolute;
    right: -4px;
    top: 20%;
    height: 60%;
    width: 1px;
    background: rgba(255,255,255,0.08);
    pointer-events: none;
}
.richbtn[data-act="quote"],
.richbtn[data-act="table"] {
    position: relative;
    margin-right: 4px;
}

.richbtn {
    width: 46px !important;
    height: 46px !important;
    min-width: 46px !important;
    min-height: 46px !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;

    display: inline-flex !important;
    align-items: center;
    justify-content: center;

    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.06);
    cursor: pointer;

    color: rgba(180,210,255,0.85);
    background: rgba(255,255,255,0.03);
    overflow: hidden;
    padding: 0 !important;
    font-size: 0;

    position: relative;
    transition: all .2s cubic-bezier(.4,0,.2,1);
}

/* 悬浮：渐变底色 + 图标提亮 + 微上浮 */
.richbtn:hover {
    background: linear-gradient(135deg, rgba(59,130,246,0.15) 0%, rgba(139,92,246,0.10) 100%);
    border-color: rgba(59,130,246,0.3);
    color: #e0ecff;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(59,130,246,0.12);
}

/* 点击按下 */
.richbtn:active {
    transform: translateY(0px) scale(0.95);
    transition-duration: .08s;
}

/* 激活态（预览开启等） */
.richbtn.active{
    background: linear-gradient(135deg, rgba(59,130,246,0.20) 0%, rgba(99,102,241,0.15) 100%);
    border: 1px solid rgba(59,130,246,0.35);
    color: #93c5fd;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.10), 0 2px 8px rgba(59,130,246,0.12);
}

/* ===== 预览按钮浮动到输入框右下角 ===== */
/* 工具栏里的预览按钮隐藏（但保留 DOM，避免影响逻辑） */
.preview-hidden{ display: none !important; }

/* textarea 外层容器：用于定位浮动按钮 */
.rich-editor__box{ position: relative; margin-top: 8px; }

/* 给输入框留出空间，避免文字/拖拽角被按钮遮挡 */
.rich-editor__box.has-float-preview textarea{
  padding-right: 56px;
  padding-bottom: 46px;
}

/* 右下角浮动预览按钮 */
.richbtn.preview-float{
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 30;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  min-height: 36px !important;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(15,23,42,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.richbtn.preview-float:hover{
  background: linear-gradient(135deg, rgba(59,130,246,0.2), rgba(139,92,246,0.15));
  border-color: rgba(59,130,246,0.3);
}
.richbtn.preview-float svg{
  width: 20px !important;
  height: 20px !important;
}

/* ===== Markdown 预览面板 ===== */
.rich-preview{
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.03);
  overflow: hidden;
}
.rich-preview__head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.rich-preview__title{
  font-weight: 700;
  font-size: 14px;
  color: rgba(255,255,255,0.88);
}
.rich-preview__close{
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.92);
  cursor: pointer;
}
.rich-preview__body{
  padding: 12px;
  max-height: 42vh;
  overflow: auto;
}
.rich-preview.is-loading .rich-preview__body{
  opacity: .85;
}

/* SVG 图标 */
.richbtn svg{
  width: 26px !important;
  height: 26px !important;
  min-width: 26px;
  min-height: 26px;
  display: block !important;
  stroke-width: 1.8;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.1));
  transition: transform .15s ease;
}
.richbtn:hover svg{
  transform: scale(1.08);
}

/* 文字图标（如 H） */
.richbtn .txt{
  font-weight: 800;
  font-size: 19px !important;
  line-height: 1;
  letter-spacing: -0.02em;
  transition: transform .15s ease;
}
.richbtn:hover .txt{
  transform: scale(1.08);
}
/* ===== Emoji Popup (像图二那种网格弹窗) ===== */
.emoji-pop{
  position: absolute;
  z-index: 9999;
  width: 560px;            /* 你可以 480~640 调整 */
  max-width: calc(100vw - 24px);
  height: 320px;           /* 固定高度，内部滚动 */
  padding: 10px;
  border-radius: 14px;
  background: rgba(16, 22, 34, .96);
  border: 1px solid rgba(255,255,255,.10);
  box-shadow: 0 14px 40px rgba(0,0,0,.45);
  overflow: hidden;
}

/* 顶部一行：标题 + 关闭按钮（可选） */
.emoji-pop .emoji-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 2px 2px 8px 2px;
  color: rgba(255,255,255,.85);
  font-size: 13px;
}

.emoji-pop .emoji-close{
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: #fff;
  cursor: pointer;
}

/* ✅ 关键：网格区域 */
.emoji-pop .emoji-grid{
  height: calc(100% - 42px); /* 扣掉 head 高度 */
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(8, 1fr); /* 一行 8 个，想更密改 9/10 */
  gap: 10px;
  padding-right: 4px;  /* 给滚动条留一点 */
}

@media (max-width: 900px){
  .emoji-pop{ width: 420px; height: 300px; }
  .emoji-pop .emoji-grid{ grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 520px){
  .emoji-pop{ width: calc(100vw - 24px); height: 280px; }
  .emoji-pop .emoji-grid{ grid-template-columns: repeat(5, 1fr); }
}

/* 单个表情按钮 */
.emoji-pop .emoji-item{
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
}

.emoji-pop .emoji-item:hover{
  border-color: rgba(59,130,246,.45);
  box-shadow: 0 0 0 3px rgba(59,130,246,.20);
}

.avatar-grid{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap:12px;
  align-items:center;
}
.avatar-pick{ cursor:pointer; display:inline-block; }
.avatar-pick img{ width:72px; height:72px; border-radius:14px; display:block; }
.avatar-pick input:checked + img{ outline:3px solid #6ea8fe; outline-offset:2px; }


/* 让图片统一大小，不会撑爆 */
.emoji-pop .emoji-item img{
  width: 100%;
  height: 100%;
  object-fit: contain;   /* 动图/贴纸常用 contain 更舒服；想填满用 cover */
  border-radius: 12px;
}
/* 贴纸/表情在帖子里显示的最大尺寸 */
.post-body img.sticker,
.reply-body img.sticker,
.content img.sticker {
  max-width: 160px;
  max-height: 160px;
  width: auto;
  height: auto;
  vertical-align: middle;
  border-radius: 8px;
  /* 回复正文里的标题也默认绿色（可选） */

}

/* 手机更小一点 */
@media (max-width: 520px) {
  .post-body img.sticker,
  .reply-body img.sticker,
  .content img.sticker {
    max-width: 120px;
    max-height: 120px;
  }
}
.sticker-viewer[hidden] { display:none; }

.sticker-viewer {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
}

.sticker-viewer__mask{
  position:absolute; inset:0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
}

/* 去掉大黑边框：panel 不要背景/内边距 */
.sticker-viewer__panel{
  position: relative;
  background: transparent;  /* 原来是深色，造成黑框 */
  padding: 0;               /* 原来有 padding，造成边框厚 */
  border: 0;
  border-radius: 0;         /* 外层不需要圆角，让图片自己圆角 */
  box-shadow: none;         /* 黑框的一部分观感也来自外层阴影 */
  max-width: 96vw;
  max-height: 96vh;
}

/* 图片本体：自己圆角 + 阴影（更高级的感觉） */
.sticker-viewer__img{
  display: block;
  max-width: 96vw;
  max-height: 96vh;
  width: auto;
  height: auto;
  border-radius: 14px; 
  box-shadow: 0 16px 48px rgba(0,0,0,.45);
}

/* 关闭按钮：放在图片右上角，不要占出黑边 */
.sticker-viewer__close{
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(0,0,0,.45);
  color: #fff;
  border: 1px solid rgba(255,255,255,.25);
  backdrop-filter: blur(6px);
}



/* ===== Preset avatars: PNG 自带圆框/留白 -> 需要放大裁切 ===== */
:root{
 --preset-scale: 1; /* 关键：调大到 1.45~1.75 之间都可以 */
}

/* 预置头像选择区：强制铺满 + 放大裁切 */
.avatar-grid .avatar-choice{
  overflow: hidden !important;
}

.avatar-grid .avatar-choice img{
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  object-position: center !important;
  transform: scale(var(--preset-scale)) !important;
  transform-origin: center center !important;
  display: block !important;
}

/* =========================================================
   Sticky header + 首页左侧栏跟随滚动（不使用 fixed，避免影响其他页）
   ========================================================= */

/* 顶部导航吸顶（你的 DOM 是 <div class="nav site-header">） */
/* 顶部导航吸顶：只在桌面端生效 */
@media (min-width: 769px){
  .nav.site-header,
  .site-header{
    position: sticky;
    top: 0;
    z-index: 1000;
  }

  html{ scroll-padding-top: 92px; }
}


/* 让锚点/滚动定位时不被顶部遮住（按你的导航高度微调 80~100px） */
html{
  scroll-padding-top: 92px;
}

/* 首页：左侧“版块/用户卡片”跟随滚动（只作用在首页 .home-grid） */
.grid.home-grid{
  align-items: flex-start;
}
.grid.home-grid > div:first-child{
  position: sticky;
  top: 92px; max-height: calc(100vh - 92px); overflow-y: auto; /* = 导航高度 + 间距，可微调 */
}

/* =========================================================
   正文图片自适应（只限制帖子/回复内容里的图片，不影响头像）
   ========================================================= */

/* ✅ 帖子/回复里的内容图片：限制显示大小（不影响头像/预置头像/表情贴纸） */
.card img:not(.avatar-img):not(.avatar-sm):not(.sticker) {
  max-width: 100% !important;            /* 兜底：至少不超出容器 */
  max-width: min(900px, 100%) !important;/* 论坛正常观看宽度，可改 780/860/1024 */
  width: auto !important;                /* 不强制拉伸，避免影响小图 */
  height: auto !important;
  max-height: 70vh;                      /* 超高长图不占满整屏 */
  object-fit: contain;
  display: block;
  margin: 10px auto;
  border-radius: 12px;
  cursor: zoom-in;
}

/* ✅ 如果某条 CSS 把段落设成居中，导致“单独一段的表情”被居中：让它强制靠左 */
.small p > img.sticker:only-child,
.markdown p > img.sticker:only-child,
.parsedown p > img.sticker:only-child{
  display: block !important;
  margin: 0 !important;
}

.small img.sticker,
.markdown img.sticker,
.parsedown img.sticker{
  display: inline-block !important;
  margin: 0 4px !important;
  vertical-align: middle;
  max-width: 160px !important;
  max-height: 160px !important;
  border-radius: 10px;
  cursor: pointer;
}

/* ✅ 预置头像/头像选择列表：覆盖上面的通用 img 规则，避免“头像炸” */
.avatar-grid img {
  width: 84px !important;
  height: 84px !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  border-radius: 18px !important; /* 圆角方形 */
  object-fit: cover !important;
  display: block;
}

@media (min-width: 769px){ .only-mobile{ display:none !important; } }
@media (max-width: 768px){ .only-mobile{ display:inline-flex !important; } }

/* ===== 移动端：适当缩小工具栏按钮 ===== */
@media (max-width: 768px) {
  .richbar {
    gap: 5px;
    padding: 8px 10px;
    border-radius: 12px;
  }
  .richbtn {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    min-height: 38px !important;
    border-radius: 10px;
  }
  .richbtn svg {
    width: 20px !important;
    height: 20px !important;
  }
  .richbtn .txt {
    font-size: 15px !important;
  }
  /* 移动端取消分隔线 */
  .richbtn[data-act="quote"]::after,
  .richbtn[data-act="table"]::after {
    display: none;
  }
  .richbtn[data-act="quote"],
  .richbtn[data-act="table"] {
    margin-right: 0;
  }
}

/* ===== 浅色主题适配 ===== */
html.theme-light .richbar,
html.theme-forest.theme-light .richbar,
html.theme-ocean.theme-light .richbar,
html.theme-minimal.theme-light .richbar {
  background: linear-gradient(135deg, rgba(0,0,0,0.03) 0%, rgba(0,0,0,0.01) 100%);
  border-color: rgba(0,0,0,0.08);
  box-shadow: 0 2px 12px rgba(0,0,0,0.04), inset 0 1px 0 rgba(255,255,255,0.8);
}
html.theme-light .richbtn,
html.theme-forest.theme-light .richbtn,
html.theme-ocean.theme-light .richbtn,
html.theme-minimal.theme-light .richbtn {
  color: rgba(30,41,59,0.7);
  background: rgba(0,0,0,0.02);
  border-color: rgba(0,0,0,0.06);
}
html.theme-light .richbtn:hover,
html.theme-forest.theme-light .richbtn:hover,
html.theme-ocean.theme-light .richbtn:hover,
html.theme-minimal.theme-light .richbtn:hover {
  color: rgba(30,41,59,0.95);
  background: linear-gradient(135deg, rgba(59,130,246,0.10) 0%, rgba(139,92,246,0.06) 100%);
  border-color: rgba(59,130,246,0.25);
  box-shadow: 0 4px 14px rgba(59,130,246,0.08);
}
html.theme-light .richbtn.active,
html.theme-forest.theme-light .richbtn.active,
html.theme-ocean.theme-light .richbtn.active,
html.theme-minimal.theme-light .richbtn.active {
  color: #2563eb;
  background: linear-gradient(135deg, rgba(59,130,246,0.12) 0%, rgba(99,102,241,0.08) 100%);
  border-color: rgba(59,130,246,0.3);
}
html.theme-light .richbtn[data-act="quote"]::after,
html.theme-light .richbtn[data-act="table"]::after {
  background: rgba(0,0,0,0.08);
}

/* 版块栏自定义滚动条美化 */
.grid.home-grid > div:first-child::-webkit-scrollbar{width:6px}
.grid.home-grid > div:first-child::-webkit-scrollbar-track{background:transparent}
.grid.home-grid > div:first-child::-webkit-scrollbar-thumb{background:rgba(148,163,184,.3);border-radius:3px}
.grid.home-grid > div:first-child::-webkit-scrollbar-thumb:hover{background:rgba(148,163,184,.5)}
.grid.home-grid > div:first-child{scrollbar-width:thin;scrollbar-color:rgba(148,163,184,.3) transparent}
