:root {
  --bg: #0b0f19;
  --card: #111827;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --pri: #2563eb;
  --danger: #dc2626;
  --ok: #16a34a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background: var(--bg);
  color: var(--text);
}

a{color:#93c5fd;text-decoration:none}
a:hover{text-decoration:underline}

/* “标题”工具（## 等 Markdown 标题）仅在正文内容中显示为绿色 */
.topic-content h1,.topic-content h2,.topic-content h3,.topic-content h4,.topic-content h5,.topic-content h6,
.post-content h1,.post-content h2,.post-content h3,.post-content h4,.post-content h5,.post-content h6{color:var(--ok)}
.topic-content h1 a,.topic-content h2 a,.topic-content h3 a,.topic-content h4 a,.topic-content h5 a,.topic-content h6 a,
.post-content h1 a,.post-content h2 a,.post-content h3 a,.post-content h4 a,.post-content h5 a,.post-content h6 a{color:var(--ok)}

.container{
  max-width:1100px;
  margin:0 auto;
  padding:16px
}

.nav{
  background:#0f172a;
  border-bottom:1px solid #1f2937
}

.nav .row{
  display:flex;
  align-items:center;
  gap:12px;
  justify-content:space-between
}

.brand{font-weight:700}

.btn{
  display:inline-block;
  padding:8px 12px;
  border-radius:10px;
  border:1px solid #334155;
  background:#111827;
  color:var(--text);
  cursor:pointer
}
.btn:hover{filter:brightness(1.1)}
.btn-primary{background:var(--pri);border-color:var(--pri)}
.btn-danger{background:var(--danger);border-color:var(--danger)}
.btn-ghost{background:transparent}

.badge{
  display:inline-block;
  padding:2px 8px;
  border-radius:999px;
  font-size:12px;
  background:#1f2937;
  color:var(--text)
}

/* 用户前缀 / 联系方式 / 签名 */
.badge-prefix{
  background:rgba(96,165,250,.15);
  border:1px solid rgba(96,165,250,.3);
}
.user-contact{margin-left:6px;}
.user-signature{
  margin-top:8px;
  padding-top:8px;
  border-top:1px solid #1f2937;
}
.user-signature p{margin:0;}

.card{
  background:var(--card);
  border:1px solid #1f2937;
  border-radius:16px;
  padding:12px;
  margin:10px 0
}

.grid{
  display:grid;
  grid-template-columns:280px 1fr;
  gap:12px
}
@media (max-width:900px){
  .grid{grid-template-columns:1fr}
}

.input,.textarea,.select{
  width:100%;
  padding:10px;
  border-radius:12px;
  border:1px solid #334155;
  background:#0b1220;
  color:var(--text)
}

.textarea{min-height:160px}

.small{
  font-size:13px;
  color:var(--muted)
}

.table{
  width:100%;
  border-collapse:collapse
}

.table th,.table td{
  padding:8px;
  border-bottom:1px solid #1f2937;
  text-align:left;
  font-size:13px
}

.kbd{
  font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;
  background:#0b1220;
  border:1px solid #334155;
  border-radius:8px;
  padding:2px 6px;
  font-size:12px
}

hr{
  border:0;
  border-top:1px solid #1f2937;
  margin:18px 0
}

.user-link{
  text-decoration: underline;
  cursor: pointer;
}
.user-link:hover{
  opacity:.85;
}

/* =========================
   主题列表 meta（点赞 / 浏览 / 回复）
   ========================= */

.topic-meta{
  display:inline-flex;
  align-items:center;
  gap:14px;
  margin-top:6px;
  font-size:13px;
  color:#94a3b8; /* 冷灰，适合深色背景 */
}

.topic-meta .meta-item{
  display:inline-flex;
  align-items:center;
  gap:4px;
  line-height:1;
  white-space:nowrap;
  user-select:none;
}

/* 回复是链接时 */
.topic-meta .meta-link{
  color:#94a3b8;
  text-decoration:none;
  transition:color .15s ease,transform .15s ease;
}

.topic-meta .meta-link:hover{
  color:#60a5fa;
  transform:translateY(-1px);
}

/* 数字等宽，防止跳动 */
.topic-meta .meta-item span,
.topic-meta .meta-item strong{
  font-variant-numeric:tabular-nums;
}

/* 整行 hover 时 meta 略微提亮 */
.topic-row:hover .topic-meta{
  color:#cbd5f5;
}
/* =========================
   Notifications
   ========================= */
.notif-item{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  padding:12px;
  border-top:1px solid #1f2937;
  border-radius:12px;
  text-decoration:none;
  color:inherit;
  transition: transform .12s ease, background .12s ease, box-shadow .12s ease;
}

.notif-item:hover{
  background: rgba(96,165,250,.08);
  transform: translateY(-1px);
}

.notif-left{
  display:flex;
  gap:10px;
  align-items:flex-start;
}

.notif-icon{
  width:34px;
  height:34px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:12px;
  background:#0b1220;
  border:1px solid #334155;
  font-size:16px;
  flex:0 0 auto;
}

.notif-main{min-width:0}
.notif-title{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:720px}
.notif-meta{display:flex;gap:8px;align-items:center;margin-top:4px}

.notif-type{
  background:#1f2937;
  border:1px solid #334155;
}

.notif-right{display:flex;align-items:center;gap:8px}

.notif-dot{
  width:10px;height:10px;border-radius:999px;
  background:#60a5fa;
  box-shadow:0 0 0 0 rgba(96,165,250,.6);
  animation:notifPulse 1.6s infinite;
}

@keyframes notifPulse{
  0%{ box-shadow:0 0 0 0 rgba(96,165,250,.55) }
  70%{ box-shadow:0 0 0 10px rgba(96,165,250,0) }
  100%{ box-shadow:0 0 0 0 rgba(96,165,250,0) }
}

.notif-item.is-read{
  opacity:.75;
}

.notif-item.is-unread{
  background: rgba(96,165,250,.06);
  border:1px solid rgba(96,165,250,.18);
}
/* ===== Notifications ===== */
.notify-toolbar{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:space-between;
}
.notify-actions{ display:flex; gap:8px; align-items:center; }

.notification-list{ padding: 6px 0; }

.notify-item{
  display:flex;
  gap:12px;
  align-items:flex-start;
  padding:12px 14px;
  border-top:1px solid rgba(255,255,255,.06);
  text-decoration:none;
  border-radius:12px;
  margin:6px 8px;
  background: rgba(255,255,255,.02);
  transition: transform .12s ease, background .12s ease, box-shadow .12s ease;
}
.notify-item:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,.04);
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
}
.notify-icon{
  width:34px;
  height:34px;
  border-radius:10px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(37,99,235,.18);
  flex: 0 0 34px;
}
.notify-body{ flex:1; min-width:0; }
.notify-title{
  font-weight:700;
  margin-bottom:4px;
  color: #cfe3ff;
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
}
.notify-meta{
  font-size:12px;
  opacity:.8;
  display:flex;
  gap:8px;
  align-items:center;
}
.badge-new{
  background: rgba(37,99,235,.25);
  border: 1px solid rgba(37,99,235,.35);
  padding:2px 8px;
  border-radius:999px;
  font-size:12px;
}
.badge-type{
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
  padding:2px 8px;
  border-radius:999px;
  font-size:12px;
}

/* unread highlight + pulse */
.notify-item.unread{
  background: rgba(37,99,235,.10);
  border: 1px solid rgba(37,99,235,.20);
}
.notify-item.unread .notify-icon{
  animation: notifyPulse 1.6s ease-in-out infinite;
}
@keyframes notifyPulse{
  0%,100%{ transform: scale(1); filter: brightness(1); }
  50%{ transform: scale(1.06); filter: brightness(1.15); }
}

.notify-chevron{
  opacity:.55;
  font-size:20px;
  line-height:20px;
  margin-top:4px;
}

/* pagination */
.pagination{
  display:flex;
  gap:8px;
  justify-content:center;
  margin-top:12px;
}
.pagination a{
  display:inline-flex;
  min-width:34px;
  height:34px;
  align-items:center;
  justify-content:center;
  border-radius:10px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
}
.pagination a.active{
  background: rgba(37,99,235,.25);
  border-color: rgba(37,99,235,.35);
}

/* =========================
   Icons (navbar / sidebar)
   ========================= */
.nav .btn .ico,
.nav .brand .ico{
  width:16px;
  height:16px;
  display:inline-block;
  vertical-align:-3px;
  margin-right:6px;
  opacity:.9;
}

.sidebar-item{
  display:flex;
  align-items:center;
  gap:8px;
}
.sidebar-item .ico{
  width:14px;
  height:14px;
  opacity:.8;
}


/* lucky draw */
.lucky-box{
  display:flex;
  gap:14px;
  align-items:flex-start;
  flex-wrap:wrap;
}
.lucky-result{
  font-weight:800;
  font-size:18px;
}


.nav-user{display:flex;align-items:center;gap:8px;}
.nav-user .pill{margin-left:0;}

/* =====================
   Lucky Draw Tool
   ===================== */
.lucky-tool-hero {
  padding: 36px 0 18px;
  background: url('/assets/gift_pattern.svg') repeat;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.lucky-tool-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.lucky-tool-title h1 {
  margin: 0;
  font-size: 40px;
  letter-spacing: 0.5px;
}
.lucky-tool-icon {
  font-size: 34px;
}
.lucky-tool-subtitle {
  margin-top: 10px;
  color: var(--text-muted);
}

.lucky-tool-card {
  margin-top: 18px;
}

.lucky-tool-form {
  display: grid;
  grid-template-columns: 1.2fr 1.1fr 0.8fr 0.7fr;
  gap: 14px;
}

@media (max-width: 1024px) {
  .lucky-tool-form {
    grid-template-columns: 1fr;
  }
}

.lucky-tool-actions {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.lucky-link-wrap {
  margin-top: 14px;
}

.lucky-result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.lucky-winner-avatar {
  width: 26px;
  height: 26px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  object-fit: cover;
}

.lucky-result-table {
  margin-top: 16px;
}

.lucky-result-table table {
  width: 100%;
  border-collapse: collapse;
}

.lucky-result-table th,
.lucky-result-table td {
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  text-align: left;
  vertical-align: top;
}

.lucky-result-table th {
  color: var(--text-muted);
  font-weight: 600;
}

.lucky-result-table td .muted {
  color: var(--text-muted);
  font-size: 12px;
}


/* =====================
   Avatar System (SINGLE)
   - 统一全站头像：圆角方形
   - 只保留一套规则，避免互相覆盖
   ===================== */
:root{
  --av-ring: rgba(59,130,246,.45);
  --av-bg: rgba(255,255,255,.06);
  --av-bd: rgba(255,255,255,.12);

  --av-xs: 22px;   /* 顶部导航 */
  --av-side: 34px; /* 侧边栏 */
  --av-sm: 40px;   /* 楼层/私信 */
  --av-lg: 96px;   /* 个人资料 */
  --av-xl: 110px;  /* 设置页预览 */

  --av-radius-xs: 8px;
  --av-radius-sm: 12px;
  --av-radius-lg: 18px;

  --preset-scale: 1.22; /* 预置头像素材自带内圈时，用放大裁切去掉内圈 */
}

/* Base container */
.avatar{
  --av: var(--av-sm);
  --av-radius: var(--av-radius-sm);
  --av-ring-w: 3px;

  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:var(--av);
  height:var(--av);
  border-radius:var(--av-radius);
  overflow:hidden;

  background:var(--av-bg);
  border:1px solid var(--av-bd);
  box-shadow:0 0 0 var(--av-ring-w) var(--av-ring);
}

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

/* Sizes */
.avatar-nav{ --av: var(--av-xs); --av-radius: var(--av-radius-xs); --av-ring-w: 2px; }
.avatar-side{ --av: var(--av-side); --av-radius: 10px; }
.avatar-sm{ --av: var(--av-sm); --av-radius: var(--av-radius-sm); }
.avatar-lg{ --av: var(--av-lg); --av-radius: var(--av-radius-lg); }
.avatar-xl{ --av: var(--av-xl); --av-radius: var(--av-radius-lg); }

/* Text fallback */
.avatar-fallback{
  font-weight:800;
  color:rgba(255,255,255,.86);
  line-height:1;
  font-size:14px;
}
.avatar-nav.avatar-fallback{ font-size:10px; }
.avatar-side.avatar-fallback{ font-size:12px; }
.avatar-lg.avatar-fallback{ font-size:20px; }

/* 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: 8px;
    padding: 8px 10px;
    min-height: 44px;

    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;

    position: relative;
    z-index: 5;
}
.richbtn {
    width: 32px;
    height: 32px;

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

    border-radius: 8px;
    cursor: pointer;

    color: #cfe1ff;
    background: transparent;
    overflow: hidden;
}

/* iOS Safari：内联 SVG 不写 width/height 时可能被裁到看不见 */
.richbtn svg{
  width: 18px;
  height: 18px;
  display: block;
}

.richbtn .txt{
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
}
/* ===== 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;
}

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

.sticker-viewer__panel{
  position:absolute;
  left:50%; top:50%;
  transform: translate(-50%, -50%);
  max-width: min(90vw, 520px);
  max-height: min(90vh, 520px);
  padding: 14px;
  border-radius: 14px;
  background: rgba(15,23,42,.95);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 10px 40px rgba(0,0,0,.35);
}

.sticker-viewer__img{
  display:block;
  max-width: 100%;
  max-height: 75vh;
  border-radius: 12px;
}

.sticker-viewer__close{
  position:absolute;
  right:10px; top:6px;
  width: 34px; height:34px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(0,0,0,.25);
  color: #fff;
  cursor: pointer;
}

/* ===== 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">） */
.nav.site-header,
.site-header{
  position: sticky;
  top: 0;
  z-index: 1000;
}

/* 让锚点/滚动定位时不被顶部遮住（按你的导航高度微调 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; /* = 导航高度 + 间距，可微调 */
}

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

/* ✅ 帖子/回复里的内容图片：限制显示大小（不影响头像/预置头像/表情贴纸） */
.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; } }

/* ===== Theme tokens ===== */
:root{
  --bg0: #0b1220;        /* 页面背景 */
  --bg1: #0f1b33;        /* 背景渐变二层 */
  --card: rgba(15,23,42,.72);
  --card2: rgba(15,23,42,.55);
  --border: rgba(51,65,85,.6);
  --text: #e5e7eb;
  --muted: rgba(229,231,235,.78);
  --primary: #3b82f6;
}

/* 白天主题 */
html.theme-light{
  --bg0: #f6f7fb;
  --bg1: #eef2ff;
  --card: rgba(255,255,255,.92);
  --card2: rgba(255,255,255,.85);
  --border: rgba(148,163,184,.45);
  --text: #0f172a;
  --muted: rgba(15,23,42,.70);
  --primary: #2563eb;
}

/* 夜间主题（你现在深色再优化一点） */
html.theme-dark{
  --bg0: #071225;
  --bg1: #0b1a38;
  --card: rgba(10,18,35,.72);
  --card2: rgba(10,18,35,.55);
  --border: rgba(51,65,85,.55);
  --text: #e5e7eb;
  --muted: rgba(229,231,235,.78);
  --primary: #3b82f6;
}

/* ===== Apply to layout ===== */
body{
  color: var(--text);
  background: radial-gradient(1200px 800px at 20% 0%, rgba(59,130,246,.16), transparent 55%),
              linear-gradient(180deg, var(--bg0), var(--bg1));
}

/* 常见卡片/容器 */
.card{
  background: var(--card);
  border: 1px solid var(--border);
}

/* 输入框/按钮（你项目里有 .input/.btn） */
.input{
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text);
}
.input::placeholder{ color: var(--muted); }

.btn{
  border: 1px solid var(--border);
  color: var(--text);
  background: rgba(255,255,255,.06);
}
.btn-primary{
  background: var(--primary);
  border-color: transparent;
  color: #fff;
}

/* 小字 */
.small, .muted{ color: var(--muted); }

/* ===== Theme tokens ===== */
:root{
  --bg0: #0b1220;        /* 页面背景 */
  --bg1: #0f1b33;        /* 背景渐变二层 */
  --card: rgba(15,23,42,.72);
  --card2: rgba(15,23,42,.55);
  --border: rgba(51,65,85,.6);
  --text: #e5e7eb;
  --muted: rgba(229,231,235,.78);
  --primary: #3b82f6;
}

/* 白天主题 */
html.theme-light{
  --bg0: #f6f7fb;
  --bg1: #eef2ff;
  --card: rgba(255,255,255,.92);
  --card2: rgba(255,255,255,.85);
  --border: rgba(148,163,184,.45);
  --text: #0f172a;
  --muted: rgba(15,23,42,.70);
  --primary: #2563eb;
}

/* 夜间主题（你现在深色再优化一点） */
html.theme-dark{
  --bg0: #071225;
  --bg1: #0b1a38;
  --card: rgba(10,18,35,.72);
  --card2: rgba(10,18,35,.55);
  --border: rgba(51,65,85,.55);
  --text: #e5e7eb;
  --muted: rgba(229,231,235,.78);
  --primary: #3b82f6;
}

/* ===== Apply to layout ===== */
body{
  color: var(--text);
  background: radial-gradient(1200px 800px at 20% 0%, rgba(59,130,246,.16), transparent 55%),
              linear-gradient(180deg, var(--bg0), var(--bg1));
}

/* 常见卡片/容器 */
.card{
  background: var(--card);
  border: 1px solid var(--border);
}

/* 输入框/按钮（你项目里有 .input/.btn） */
.input{
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text);
}
.input::placeholder{ color: var(--muted); }

.btn{
  border: 1px solid var(--border);
  color: var(--text);
  background: rgba(255,255,255,.06);
}
.btn-primary{
  background: var(--primary);
  border-color: transparent;
  color: #fff;
}

/* 小字 */
.small, .muted{ color: var(--muted); }

/* ===== Theme menu ===== */
.theme-wrap{
  position: relative;
  display: inline-flex;
  align-items: center;
}

.theme-menu{
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  backdrop-filter: blur(10px);
  display: none;
  z-index: 10000;
}

.theme-menu.open{ display: block; }

.theme-item{
  width: 100%;
  text-align: left;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.theme-item:hover{
  background: rgba(255,255,255,.06);
  border-color: var(--border);
}

/* ===== Icon buttons ===== */
.btn.btn-icon{
  padding-left: 10px;
  padding-right: 10px;
}

/* ===== User menu ===== */
.user-menu-wrap{
  position: relative;
  display: inline-flex;
  align-items: center;
}
.user-menu{
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  backdrop-filter: blur(10px);
  display: none;
  z-index: 10000;
}
.user-menu.open{ display:block; }

.user-menu-item{
  width: 100%;
  display: block;
  text-align: left;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.user-menu-item:hover{
  background: rgba(255,255,255,.06);
  border-color: var(--border);
}

.user-menu-sep{
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}

.user-menu-logout{
  border: 0;
  background: transparent;
}

.user-menu-caret{
  margin-left: 2px;
  opacity: .8;
}

/* 手机端：菜单改成靠左或全宽都行（这里做小优化） */
@media (max-width: 768px){
  .theme-menu{
    left: 0;
    right: auto;
    min-width: 220px;
  }
}
/* =========================
   Theme variables + apply
   (append to END of app.css)
   ========================= */

:root{
  --nav-bg: #0f172a;
  --border: #1f2937;
  --btn-bg: #111827;
  --btn-border: #334155;
  --input-bg: #0b1220;
  --badge-bg: #1f2937;
  --link: #93c5fd;
}

/* 让组件跟随变量 */
body{ background: var(--bg); color: var(--text); }
a{ color: var(--link); }
.nav{ background: var(--nav-bg); border-bottom: 1px solid var(--border); }
.card{ background: var(--card); border: 1px solid var(--border); }
.btn{ background: var(--btn-bg); border: 1px solid var(--btn-border); color: var(--text); }
.input,.textarea,.select{ background: var(--input-bg); border: 1px solid var(--btn-border); color: var(--text); }
.badge{ background: var(--badge-bg); color: var(--text); }
.table th,.table td{ border-bottom: 1px solid var(--border); }

/* =========================
   Theme packs (5 themes × light/dark)
   ========================= */

/* Ocean 深海蓝 */
html.theme-ocean.theme-dark{
  --bg:#0b0f19; --card:#111827; --text:#e5e7eb; --muted:#9ca3af;
  --pri:#2563eb; --danger:#dc2626; --ok:#16a34a;
  --nav-bg:#0f172a; --border:#1f2937; --btn-bg:#111827; --btn-border:#334155;
  --input-bg:#0b1220; --badge-bg:#1f2937; --link:#93c5fd;
}
html.theme-ocean.theme-light{
  --bg:#f5f8ff; --card:#ffffff; --text:#0f172a; --muted:#64748b;
  --pri:#2563eb; --danger:#dc2626; --ok:#16a34a;
  --nav-bg:#ffffff; --border:#e5e7eb; --btn-bg:#ffffff; --btn-border:#d1d5db;
  --input-bg:#ffffff; --badge-bg:#eef2ff; --link:#2563eb;
}

/* Minimal 极简 */
html.theme-minimal.theme-dark{
  --bg:#0b0b0c; --card:#141416; --text:#f3f4f6; --muted:#9ca3af;
  --pri:#a3a3a3; --danger:#ef4444; --ok:#22c55e;
  --nav-bg:#0e0e10; --border:#262626; --btn-bg:#141416; --btn-border:#2f2f2f;
  --input-bg:#101012; --badge-bg:#1b1b1f; --link:#e5e7eb;
}
html.theme-minimal.theme-light{
  --bg:#fafafa; --card:#ffffff; --text:#111827; --muted:#6b7280;
  --pri:#111827; --danger:#dc2626; --ok:#16a34a;
  --nav-bg:#ffffff; --border:#e5e7eb; --btn-bg:#ffffff; --btn-border:#d1d5db;
  --input-bg:#ffffff; --badge-bg:#f3f4f6; --link:#111827;
}

/* Obsidian 黑金 */
html.theme-obsidian.theme-dark{
  --bg:#070708; --card:#111014; --text:#f5f3ff; --muted:#a1a1aa;
  --pri:#d4af37; --danger:#ef4444; --ok:#22c55e;
  --nav-bg:#0a0a0d; --border:#27272a; --btn-bg:#111014; --btn-border:#3f3f46;
  --input-bg:#0c0c10; --badge-bg:#1a1a22; --link:#f7d774;
}
html.theme-obsidian.theme-light{
  --bg:#fffaf0; --card:#ffffff; --text:#1f2937; --muted:#6b7280;
  --pri:#b8860b; --danger:#dc2626; --ok:#16a34a;
  --nav-bg:#ffffff; --border:#e5e7eb; --btn-bg:#ffffff; --btn-border:#d1d5db;
  --input-bg:#ffffff; --badge-bg:#fff3cd; --link:#b8860b;
}

/* Neon 霓虹 */
html.theme-neon.theme-dark{
  --bg:#050611; --card:#0b1024; --text:#e5e7eb; --muted:#9ca3af;
  --pri:#a855f7; --danger:#fb7185; --ok:#22c55e;
  --nav-bg:#070a18; --border:#1f2a4a; --btn-bg:#0b1024; --btn-border:#27345a;
  --input-bg:#060a18; --badge-bg:#131a35; --link:#60a5fa;
}
html.theme-neon.theme-light{
  --bg:#fbf7ff; --card:#ffffff; --text:#111827; --muted:#6b7280;
  --pri:#7c3aed; --danger:#e11d48; --ok:#16a34a;
  --nav-bg:#ffffff; --border:#e5e7eb; --btn-bg:#ffffff; --btn-border:#d1d5db;
  --input-bg:#ffffff; --badge-bg:#f3e8ff; --link:#7c3aed;
}

/* Forest 森林 */
html.theme-forest.theme-dark{
  --bg:#07110b; --card:#0e1a12; --text:#ecfdf5; --muted:#9ca3af;
  --pri:#16a34a; --danger:#ef4444; --ok:#22c55e;
  --nav-bg:#08140d; --border:#1f3a2a; --btn-bg:#0e1a12; --btn-border:#2b4d37;
  --input-bg:#08140d; --badge-bg:#13261a; --link:#86efac;
}
html.theme-forest.theme-light{
  --bg:#f3fff7; --card:#ffffff; --text:#0f172a; --muted:#64748b;
  --pri:#16a34a; --danger:#dc2626; --ok:#16a34a;
  --nav-bg:#ffffff; --border:#e5e7eb; --btn-bg:#ffffff; --btn-border:#d1d5db;
  --input-bg:#ffffff; --badge-bg:#dcfce7; --link:#16a34a;
}
/* ===== Stickers inline + never centered ===== */
.markdown img.sticker,
.parsedown img.sticker,
.small img.sticker {
  display: inline-block !important;
  margin: 0 4px !important;
  vertical-align: middle !important;
  max-width: 160px !important;
  max-height: 160px !important;
}

/* 如果父级 p 被设置了 text-align:center，会导致 inline-block 也居中 */
.markdown p:has(img.sticker),
.parsedown p:has(img.sticker),
.small p:has(img.sticker) {
  text-align: left !important;
}

/* 万一某处用了 flex 居中 */
.markdown p:has(img.sticker),
.parsedown p:has(img.sticker),
.small p:has(img.sticker) {
  display: block !important;
}

/* ===== 头像永远不缩小，用户名太长会显示 ... ===== */
.nav-user{display:flex;align-items:center;gap:8px;min-width:0;max-width:240px;}
.nav-user .avatar-nav{flex:0 0 auto;}
.nav-user .pill{flex:0 0 auto;margin-left:0;}
.nav-user .nav-username{
  min-width:0;
  flex:1 1 auto;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  display:block;
}

.sticker-tabs{display:flex;gap:8px;overflow-x:auto;padding:10px 12px;border-bottom:1px solid rgba(255,255,255,.12)}
.sticker-tab{padding:6px 10px;border-radius:999px;background:rgba(255,255,255,.08);color:#fff;cursor:pointer;white-space:nowrap;font-size:13px}
.sticker-tab.active{background:rgba(255,255,255,.18)}
/* 仅表情包弹窗用 flex，避免影响其它 emoji 弹窗 */
.emoji-pop.sticker-pop{
  display:flex;
  flex-direction:column;
}

/* 表情包网格：不依赖 aspect-ratio（兼容 iOS/桌面），每格强制正方形 */
.emoji-pop.sticker-pop .sticker-grid{
  --cell: 96px;
  flex: 1 1 auto;
  min-height: 0;          /* 允许在 flex 容器内滚动 */
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--cell), 1fr));
  gap: 10px;
  padding: 10px;
  padding-right: 4px;
  align-content: start;
  height: auto;
}
@media (max-width: 520px){
  .emoji-pop.sticker-pop .sticker-grid{ --cell: 88px; gap: 8px; padding: 8px; }
}

.emoji-pop.sticker-pop .sticker-item{
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  overflow: hidden;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

/* 关键：用 padding-bottom 强制正方形，占位不乱 */
.emoji-pop.sticker-pop .sticker-item::before{
  content: '';
  display: block;
  width: 100%;
  padding-bottom: 100%;
}


.emoji-pop.sticker-pop .sticker-item img{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;     /* 不裁切；想铺满改 cover */
  display:block;
}

.emoji-img{
  display:inline-block;
  vertical-align:middle;
  width:64px;
  height:64px;
  object-fit:contain;
  margin:0 4px;
}

/* 只控制表情，不影响普通帖子图片 */
img.emoji-img{
  display:inline-block !important;
  vertical-align:middle !important;

  width:74px !important;
  height:74px !important;
  max-width:74px !important;
  max-height:74px !important;

  margin:0 4px !important;
  object-fit:contain !important;
}

/* 关键：让 hidden 真正隐藏弹窗（否则 X 关不掉） */
.emoji-pop[hidden]{display:none !important;}

/* 表情包方块网格（两端都稳） */
.emoji-pop.sticker-pop .sticker-grid{
--cell:96px;
  height:calc(100% - 42px - 52px);
  overflow:auto;
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(var(--cell), 1fr));
  grid-auto-rows:var(--cell);
  gap:10px;
  padding:12px;
  padding-right:4px;
  align-content:start;
}

@media (max-width:520px){
.emoji-pop.sticker-pop .sticker-grid{--cell:84px;gap:8px;padding:8px;}
}
.emoji-pop.sticker-pop .sticker-item{padding:0 !important;overflow:hidden;border-radius:12px;}
.emoji-pop.sticker-pop .sticker-item img{width:100%;height:100%;object-fit:contain;display:block;}

/* 回复正文里的标题也默认绿色（可选） */

