/* 墨白社区 - 样式（黑白极简，移动端优先） */
:root {
  --bg: #ffffff;
  --bg-soft: #f5f5f5;
  --ink: #111111;
  --muted: #999999;
  --line: #e8e8e8;
  --accent: #111111;
  --accent-soft: #f0f0f0;
  --danger: #d9534f;
  --radius: 12px;
  --tab-h: 56px;
  --nav-h: 48px;
}

/* 深色模式 */
body.dark {
  --bg: #111111;
  --bg-soft: #1e1e1e;
  --ink: #f0f0f0;
  --muted: #888888;
  --line: #2a2a2a;
  --accent: #f0f0f0;
  --accent-soft: #2a2a2a;
}
body.dark .badge.top { background: #3a2f00; color: #ffd54f; }
body.dark .badge.essence { background: #3a1a1a; color: #ff8a80; }
body.dark .cat-tab.active { background: #f0f0f0; color: #111; }
body.dark .btn { background: #f0f0f0; color: #111; }
body.dark .btn.ghost { background: #2a2a2a; color: #f0f0f0; }
body.dark .btn.danger { background: #111; color: #ff8a80; border-color: #ff8a80; }
body.dark .fab { background: #f0f0f0; color: #111; }
body.dark .post-avatar { background: #f0f0f0; color: #111; }
body.dark .profile-avatar { background: #f0f0f0; color: #111; }
body.dark .admin-avatar { background: #f0f0f0; color: #111; }

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  overflow: hidden;
}

#app { width: 100%; height: 100%; display: flex; flex-direction: column; }

/* ---- 顶部导航栏 ---- */
.navbar {
  height: var(--nav-h);
  min-height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  flex-shrink: 0;
}
.navbar .title { font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.navbar .nav-btn { font-size: 22px; cursor: pointer; padding: 4px 6px; color: var(--ink); line-height: 1; }
.navbar .nav-btn:active { opacity: 0.5; }

/* ---- 主内容区 ---- */
.main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.view { display: none; min-height: 100%; }
.view.active { display: block; }

/* ---- 分类 Tab ---- */
.cat-tabs {
  display: flex;
  overflow-x: auto;
  padding: 10px 12px;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
  -webkit-overflow-scrolling: touch;
}
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
  flex-shrink: 0;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg-soft);
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid transparent;
}
.cat-tab.active { background: var(--accent); color: #fff; font-weight: 600; }

/* ---- 帖子列表 ---- */
.post-list { padding: 0; }
.post-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  display: flex;
  gap: 12px;
}
.post-item:active { background: var(--bg-soft); }
.post-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 16px;
  flex-shrink: 0;
}
.post-body { flex: 1; min-width: 0; }
.post-title { font-size: 15px; font-weight: 600; line-height: 1.4; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-meta { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.post-meta .tag { padding: 1px 6px; border-radius: 3px; background: var(--accent-soft); color: var(--ink); font-size: 11px; }
.badge { padding: 1px 6px; border-radius: 3px; font-size: 11px; }
.badge.top { background: #fff3cd; color: #856404; }
.badge.essence { background: #f8d7da; color: #721c24; }

/* ---- 空状态 ---- */
.empty { text-align: center; color: var(--muted); padding: 60px 20px; font-size: 14px; }
.empty .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }

/* ---- 底部 Tab 栏 ---- */
.tabbar {
  height: var(--tab-h);
  min-height: var(--tab-h);
  display: flex;
  border-top: 1px solid var(--line);
  background: var(--bg);
  flex-shrink: 0;
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  color: var(--muted);
}
.tab-item .ico { font-size: 22px; line-height: 1; }
.tab-item .lbl { font-size: 11px; }
.tab-item.active { color: var(--accent); font-weight: 600; }

/* ---- 发帖按钮（浮动）---- */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(var(--tab-h) + 20px);
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 100;
}
.fab:active { transform: scale(0.92); }

/* ---- 表单 ---- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input, .textarea, select.input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  background: var(--bg);
  color: var(--ink);
  outline: none;
}
.input:focus, .textarea:focus { border-color: var(--accent); }
.textarea { min-height: 120px; resize: vertical; }
.btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 2px;
}
.btn:active { opacity: 0.85; }
.btn.ghost { background: var(--accent-soft); color: var(--ink); }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid var(--danger); }
.btn.small { width: auto; padding: 7px 16px; font-size: 13px; letter-spacing: 0; }

/* ---- 弹窗 ---- */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
}
.mask.show { display: flex; }
.sheet {
  width: 100%;
  max-height: 88%;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto;
  animation: slideUp 0.25s ease;
}
.sheet .sheet-title { font-size: 17px; font-weight: 700; text-align: center; margin-bottom: 16px; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ---- 帖子详情 ---- */
.detail-header { padding: 18px 16px; border-bottom: 1px solid var(--line); }
.detail-title { font-size: 20px; font-weight: 700; line-height: 1.4; margin-bottom: 10px; }
.detail-author { display: flex; align-items: center; gap: 10px; }
.detail-content { padding: 16px; font-size: 15px; line-height: 1.8; white-space: pre-wrap; word-break: break-word; }
.detail-actions { display: flex; justify-content: space-around; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 16px; }
.detail-action { display: flex; align-items: center; gap: 4px; cursor: pointer; color: var(--muted); font-size: 14px; }
.detail-action:active { opacity: 0.6; }
.detail-action.liked { color: var(--danger); }

/* ---- 回复列表 ---- */
.reply-list { padding: 0 16px; }
.reply-item { padding: 14px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; }
.reply-floor { font-size: 11px; color: var(--muted); flex-shrink: 0; width: 34px; text-align: center; background: var(--bg-soft); border-radius: 4px; padding: 2px 0; height: fit-content; }
.reply-content { flex: 1; font-size: 14px; line-height: 1.6; word-break: break-word; }
.reply-author { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

/* ---- 回复输入条 ---- */
.reply-bar {
  display: flex;
  gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
  flex-shrink: 0;
}
.reply-bar .input { flex: 1; }
.reply-bar .btn { width: auto; padding: 0 20px; }

/* ---- 个人中心 ---- */
.profile-head { text-align: center; padding: 30px 16px 20px; }
.profile-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 30px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
}
.profile-name { font-size: 18px; font-weight: 700; }
.profile-bio { font-size: 13px; color: var(--muted); margin-top: 4px; }
.profile-menu { border-top: 1px solid var(--line); }
.menu-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.menu-item:active { background: var(--bg-soft); }
.menu-item .l { display: flex; align-items: center; gap: 10px; }
.menu-item .arrow { color: var(--muted); }

/* ---- 私信 ---- */
.conv-item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.conv-item:active { background: var(--bg-soft); }
.conv-unread {
  min-width: 18px; height: 18px;
  background: var(--danger);
  color: #fff;
  border-radius: 9px;
  font-size: 11px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}
.chat-msg { margin: 10px 16px; max-width: 75%; padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.5; word-break: break-word; }
.chat-msg.me { margin-left: auto; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.other { margin-right: auto; background: var(--bg-soft); border-bottom-left-radius: 4px; }
.chat-msg .time { font-size: 10px; opacity: 0.6; margin-top: 4px; }

/* ---- 管理后台 ---- */
.admin-header { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--line); }
.admin-header .sheet-title { margin: 0; text-align: left; }
.admin-section { padding: 16px; }
.admin-section-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; }
.admin-row { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; }
.admin-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 16px; flex-shrink: 0; }
.admin-info { flex: 1; min-width: 0; }
.admin-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.admin-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.admin-actions .btn.small { padding: 5px 12px; font-size: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; text-align: center; }
.stat-icon { font-size: 22px; margin-bottom: 4px; }
.stat-val { font-size: 20px; font-weight: 700; }
.stat-label { font-size: 11px; color: var(--muted); margin-top: 2px; }
.log-item { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.log-detail { font-size: 13px; margin-top: 4px; }

/* ---- 图片 ---- */
.post-thumb { margin: 8px 0; border-radius: 8px; overflow: hidden; }
.post-thumb img { width: 100%; max-height: 160px; object-fit: cover; display: block; }
.detail-images { margin-top: 12px; }
.detail-images img { width: 100%; border-radius: 8px; margin-bottom: 8px; display: block; }
.img-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.img-preview-item { position: relative; width: 72px; height: 72px; }
.img-preview-item img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.img-remove { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; background: var(--danger); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; cursor: pointer; line-height: 1; }

/* ---- 加载更多 ---- */
.load-more { text-align: center; padding: 14px; color: var(--muted); font-size: 13px; cursor: pointer; }
.load-more:active { opacity: 0.6; }

/* ---- 工具类 ---- */
.hidden { display: none !important; }
.toast {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 300;
  pointer-events: none;
}

/* ---- 启动公告弹窗（居中卡片，区别于底部 sheet） ---- */
.announce-mask { align-items: center; z-index: 250; }
.announce-card {
  position: relative;
  width: 82%;
  max-width: 320px;
  background: var(--bg);
  border-radius: 16px;
  padding: 26px 22px 18px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  animation: announceIn 0.28s ease;
}
@keyframes announceIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.announce-title {
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.announce-content {
  font-size: 15px;
  line-height: 1.8;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 46vh;
  overflow-y: auto;
}
.announce-countdown {
  margin-top: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.announce-countdown span {
  display: inline-block;
  min-width: 18px;
  font-weight: 700;
  color: var(--ink);
}
.announce-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}
.announce-close:active { opacity: 0.6; }
body.dark .announce-card { box-shadow: 0 12px 40px rgba(0,0,0,0.6); }

/* ---- 云同步状态条 ---- */
.sync-status {
  text-align: center;
  font-size: 12px;
  color: var(--text-light, #999);
  padding: 10px 16px 2px;
  cursor: pointer;
}


.announce-toggle { margin-bottom: 14px; }
.announce-switch { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.announce-switch input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---- 交流群 / 意见反馈 ---- */
.profile-version { text-align: center; color: var(--muted); font-size: 12px; padding: 18px 0 26px; }
.group-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.group-num { font-size: 20px; font-weight: 700; letter-spacing: 1px; }
.group-qr { width: 100%; max-width: 240px; border: 1px solid var(--line); border-radius: 8px; display: block; margin: 0 auto; }
.feedback-content { font-size: 14px; line-height: 1.6; margin-top: 4px; white-space: pre-wrap; word-break: break-word; }

/* ---- 等级徽章 / 管理后台权限控件 ---- */
.badge-lv { padding: 1px 7px; border-radius: 3px; background: var(--accent-soft); color: var(--ink); font-size: 11px; }
.badge.mod { background: #d1ecf1; color: #0c5460; }
.mod-actions {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.admin-priv { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.admin-select {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font-size: 12px;
}
.admin-tip {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

/* ============================================
   网页版 · 桌面端宽屏适配（≥768px）
   手机浏览器仍走上面的移动端布局，自动降级
   ============================================ */
@media (min-width: 768px) {
  /* 浏览器背景加深，衬托居中的 App 主体 */
  body { background: var(--bg-soft); }

  /* App 主体居中限宽，像独立应用窗口 */
  #app {
    max-width: 1100px;
    margin: 0 auto;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.08);
  }

  /* 帖子列表：双栏卡片 */
  .post-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 14px;
  }
  .post-item {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
  }
  .post-item:hover { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08); transform: translateY(-1px); }

  /* 详情页正文限宽居中，长文更好读 */
  .detail-content { max-width: 720px; margin: 0 auto; }
  .detail-header { max-width: 720px; margin: 0 auto; }
  .detail-actions { max-width: 720px; margin: 0 auto; }

  /* 弹窗（发帖 / 登录 / 交流群等）：居中卡片而不是底部抽屉 */
  .sheet {
    width: auto;
    min-width: 320px;
    max-width: 460px;
    border-radius: 16px;
    margin: 0 auto;
  }

  /* 浮动发帖按钮：跟随 App 主体右缘，不跑到浏览器最右边 */
  .fab {
    right: max(20px, calc(50vw - 530px));
    bottom: 30px;
  }

  /* 管理后台 / 个人中心等页面限宽居中 */
  .admin-header, .admin-section, .profile-head, .profile-menu, .profile-version, .sync-status {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
  }

  /* 后台统计卡片：宽屏下 4 列 */
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

