/* X-DUCK 社区样式（/community.html）
   ============================================================

   设计 token 一律来自 `account.css`（--bg / --surface / --brand / --r-md …），
   本文件**不重新定义颜色**，只写社区自己的版式。

   为什么这样做：社区页原来带一套自己的内联样式（--brand:#2f6fed 蓝色 + 明暗
   双主题），和账号中心（琥珀 #f2a93b）是两种视觉语言 —— 从账号中心点进社区
   像换了家公司。现在两页共用同一套 token，`account.css` 先加载、本文件只做增量。

   因此这里可以直接用 account.css 已有的 .btn / .input / .field / .side-item /
   .badge / .mono / .muted-txt，不重复实现按钮和输入框。

   版式：三栏（左导航 208 / 中间信息流 / 右栏 292），与参考稿一致。
   ============================================================ */

/* ---------------------------------------------------------------- 骨架 */
.cm-app { display: flex; flex-direction: column; min-height: 100vh; background: var(--bg); }

/* 头像：账号中心是圆形，社区信息流用**圆角方**（与参考稿一致）。
   方头像和标题左边缘能对齐，信息流扫读时更整齐。 */
.cm-app .avatar { border-radius: 10px; overflow: hidden; flex: 0 0 auto; }
.cm-app .avatar svg,
.cm-app .avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }

/* ---------------------------------------------------------------- 顶栏 */
.cm-top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.cm-brand { font-weight: 700; letter-spacing: .26em; color: var(--brand); font-size: 12.5px; }
.cm-crumb { font-size: 12px; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--border); }

.cm-search { position: relative; margin-left: auto; width: 240px; max-width: 34vw; }
.cm-search svg {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--muted-2); pointer-events: none;
}
.cm-search input {
  width: 100%; height: 30px; padding: 0 26px 0 28px;
  font: inherit; font-size: 12.5px; color: var(--fg);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-pill);
  outline: none; transition: border-color .12s ease, background .12s ease;
}
.cm-search input::placeholder { color: var(--muted-2); }
.cm-search input:focus { border-color: var(--brand); background: var(--bg); }
.cm-search .clr {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted-2);
  font-size: 15px; line-height: 1; cursor: pointer;
}
.cm-search .clr:hover { background: var(--surface-3); color: var(--fg); }

.cm-who {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 10px 0 4px;
  background: transparent; border: 1px solid var(--border); border-radius: var(--r-pill);
  color: var(--fg); cursor: pointer; max-width: 180px;
}
.cm-who:hover { background: var(--surface-2); border-color: var(--border-strong); }
.cm-who .avatar { width: 24px; height: 24px; border-radius: 7px; font-size: 10px; }
.cm-who b { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- 三栏 */
.cm-body {
  width: 100%; max-width: 1280px; margin: 0 auto;
  padding: 18px 20px 56px;
  display: grid; grid-template-columns: 208px minmax(0, 1fr) 292px;
  gap: 18px; align-items: start;
}

/* ---------------------------------------------------------------- 左导航 */
.cm-side { position: sticky; top: 70px; display: flex; flex-direction: column; }

.cm-me {
  display: flex; align-items: center; gap: 10px;
  padding: 0 2px 14px; margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.cm-me .avatar { width: 40px; height: 40px; border-radius: 12px; font-size: 14px; }
.cm-me .nm { font-size: 12.5px; font-weight: 600; color: var(--fg-strong); line-height: 1.35; }
.cm-me .un {
  font-size: 10.5px; color: var(--muted-2); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cm-me .txt { min-width: 0; flex: 1; }

/* .side-item 来自 account.css（34px 高 / 左侧 2px 高亮 / .on 用 brand-soft）。
   这里只补 button 元素需要的复位和右侧计数。 */
.cm-side button.side-item {
  width: 100%; border: 0; border-left: 2px solid transparent;
  background: transparent; font: inherit; font-size: 12.5px;
  text-align: left; border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.cm-side button.side-item.on { border-left-color: var(--brand); }
.cm-side .side-cap { padding: 14px 2px 6px; }
.cm-cnt {
  margin-left: auto; font-family: var(--font-mono); font-size: 10.5px;
  color: var(--muted-2); font-variant-numeric: tabular-nums;
}
/* 交流室在线人数：一个绿点 + 等宽数字。绿点是"这是活的"的暗示，
   等宽字避免人数从 9 → 10 时整行文字左右抖一下。 */
.cm-live { display: inline-flex; align-items: center; gap: 5px; color: var(--success); }
.cm-live::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; flex: 0 0 auto;
}
.cm-dot { width: 7px; height: 7px; border-radius: 2px; flex: 0 0 auto; }
.cm-dot svg { width: 9px; height: 9px; }
.cm-dot.c-all { background: none; display: grid; place-items: center; width: 9px; height: 9px; color: var(--muted-2); }
/* 分类色：沿用账号中心的角色色板，语义上也不冲突 */
.cm-dot.c-general { background: var(--muted-2); }
.cm-dot.c-energy  { background: var(--role-ef); }
.cm-dot.c-review  { background: var(--down); }
.cm-dot.c-ask     { background: var(--info); }
.cm-dot.c-suggest { background: var(--brand); }
.cm-dot.c-notice  { background: var(--up); }

.cm-side-foot { margin-top: 14px; padding: 10px 2px 0; border-top: 1px solid var(--border);
  font-size: 10.5px; line-height: 1.7; color: var(--muted-2); }
.cm-side-foot b { color: var(--muted); font-weight: 600; }

/* ---------------------------------------------------------------- 中间栏 */
.cm-main { min-width: 0; }

/* 发帖区：参考稿是「头像 + 一句占位 + 分类 + 发帖」的一行，点任意处展开成弹窗。
   不做成常驻大输入框 —— 信息流才是主角，输入区占太多高度会把帖子挤到首屏之外。 */
.cm-composer {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
}
.cm-composer .avatar { width: 32px; height: 32px; border-radius: 9px; font-size: 11px; }
.cm-fake {
  flex: 1; min-width: 0; height: 34px; padding: 0 12px;
  display: flex; align-items: center;
  font: inherit; font-size: 12.5px; color: var(--muted-2); text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  cursor: text; transition: border-color .12s ease, color .12s ease;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cm-fake:hover { border-color: var(--border-strong); color: var(--muted); }
.cm-composer .btn { flex: 0 0 auto; height: 30px; font-size: 12px; padding: 0 12px; }

/* 原生 select 在深色主题里默认是白底黑字，必须显式上色 */
.cm-select {
  height: 30px; padding: 0 6px; flex: 0 0 auto;
  font: inherit; font-size: 12px; color: var(--fg);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); outline: none; cursor: pointer;
}
.cm-select:focus { border-color: var(--brand); }
.cm-select option { background: var(--surface); color: var(--fg); }

.cm-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.cm-tabs {
  display: inline-flex; gap: 2px; padding: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
}
.cm-tabs button {
  height: 26px; padding: 0 11px; border: 0; border-radius: 4px;
  background: transparent; color: var(--muted); font-size: 12px; cursor: pointer;
}
.cm-tabs button:hover { color: var(--fg); }
.cm-tabs button.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.cm-hint { font-size: 11px; color: var(--muted-2); }

/* 生效中的筛选条件（搜索词 / 标签 / 分类 / 视角），可单独摘掉 */
.cm-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.cm-chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 4px 0 9px;
  font-size: 11px; color: var(--fg);
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r-pill);
}
.cm-chip button {
  width: 16px; height: 16px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent;
  color: var(--muted-2); font-size: 13px; line-height: 1; cursor: pointer;
}
.cm-chip button:hover { background: var(--surface-3); color: var(--danger); }

/* ---------------------------------------------------------------- 帖子卡 */
.cm-list { display: flex; flex-direction: column; gap: 10px; }
.cm-post {
  display: flex; gap: 12px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  cursor: pointer; transition: border-color .12s ease, background .12s ease;
}
.cm-post:hover { border-color: var(--border-strong); background: var(--surface-3); }
.cm-post .avatar { width: 34px; height: 34px; border-radius: 10px; font-size: 12px; }
.cm-post .main { flex: 1; min-width: 0; }

.cm-post .head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 11px; color: var(--muted-2); }
.cm-post .head .nm { font-size: 12px; font-weight: 600; color: var(--fg); }
.cm-post .head .sep { color: var(--border-strong); }

.cm-cat-pill {
  display: inline-flex; align-items: center; height: 18px; padding: 0 7px;
  border-radius: var(--r-pill); font-size: 10.5px; font-weight: 600;
  border: 1px solid transparent; white-space: nowrap;
}
.cm-cat-pill.c-general { color: var(--muted); background: var(--surface-3); border-color: var(--border-strong); }
.cm-cat-pill.c-energy  { color: #d2a8ff; background: rgba(163, 113, 247, .13); border-color: rgba(163, 113, 247, .38); }
.cm-cat-pill.c-review  { color: var(--down); background: rgba(38, 166, 154, .12); border-color: rgba(38, 166, 154, .38); }
.cm-cat-pill.c-ask     { color: var(--info); background: rgba(88, 166, 255, .12); border-color: rgba(88, 166, 255, .38); }
.cm-cat-pill.c-suggest { color: var(--brand); background: var(--brand-soft); border-color: rgba(242, 169, 59, .4); }
.cm-cat-pill.c-notice  { color: #fff; background: var(--up); border-color: var(--up); }

.cm-post h3 {
  margin: 7px 0 4px; font-size: 14.5px; font-weight: 600; line-height: 1.45;
  color: var(--fg-strong); word-break: break-word;
}
.cm-post:hover h3 { color: var(--brand); }
.cm-post .ex {
  margin: 0; font-size: 12.5px; line-height: 1.65; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}
.cm-post .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.cm-tag-btn {
  height: 20px; padding: 0 8px; border-radius: var(--r-pill);
  font-size: 10.5px; color: var(--muted);
  background: transparent; border: 1px solid var(--border); cursor: pointer;
}
.cm-tag-btn:hover { color: var(--brand); border-color: var(--brand); }

.cm-post .foot { display: flex; align-items: center; gap: 4px; margin-top: 10px; }
.cm-act {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 7px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--muted-2); font-size: 11.5px; cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.cm-act svg { width: 13px; height: 13px; }
.cm-act:hover { background: var(--surface-3); color: var(--fg); }
.cm-act.like.on { color: var(--danger); }
.cm-act.like.on svg { fill: currentColor; }
.cm-act.book.on { color: var(--brand); }
.cm-act.book.on svg { fill: currentColor; }
.cm-act.del:hover { color: var(--danger); }
/* 浏览量是只读数字，不能长得像按钮 */
.cm-act.stat { cursor: default; }
.cm-act.stat:hover { background: transparent; color: var(--muted-2); }
.cm-post .foot .right { margin-left: auto; display: flex; gap: 2px; }

/* ---------------------------------------------------------------- 空态 / 翻页 */
.cm-empty { padding: 44px 20px; text-align: center; }
.cm-empty .t { font-size: 13px; color: var(--fg); }
.cm-empty .d { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.cm-empty .btn { margin-top: 14px; }

.cm-pager {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: 16px; font-size: 11.5px; color: var(--muted);
}
.cm-pager .btn { height: 28px; font-size: 12px; }
.cm-pager .mono { color: var(--muted); }

/* ---------------------------------------------------------------- 详情 */
.cm-detail { display: none; }
body.cm-view-detail .cm-listview { display: none; }
body.cm-view-detail .cm-detail { display: block; }
.cm-back { margin-bottom: 12px; height: 28px; font-size: 12px; }

.cm-article {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 18px 20px;
}
.cm-article .head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; font-size: 11px; color: var(--muted-2); }
.cm-article .head .avatar { width: 34px; height: 34px; border-radius: 10px; font-size: 12px; }
.cm-article .head .nm { font-size: 12.5px; font-weight: 600; color: var(--fg); }
.cm-article h1 {
  margin: 14px 0 12px; font-size: 19px; line-height: 1.45; font-weight: 600; color: var(--fg-strong);
  word-break: break-word;
}
.cm-article .body {
  font-size: 13.5px; line-height: 1.85; color: var(--fg);
  white-space: pre-wrap; word-break: break-word;
}
.cm-article .foot {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border);
}
.cm-article .foot .right { margin-left: auto; display: flex; gap: 4px; }

.cm-cmt-panel { margin-top: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.cm-cmt-n { font-weight: 400; color: var(--muted-2); font-size: 11.5px; }
.cm-cmt { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.cm-cmt:last-child { border-bottom: 0; }
.cm-cmt .avatar { width: 26px; height: 26px; border-radius: 8px; font-size: 10px; }
.cm-cmt .main { flex: 1; min-width: 0; }
.cm-cmt .head { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted-2); }
.cm-cmt .head .nm { font-size: 11.5px; font-weight: 600; color: var(--fg); }
.cm-cmt .txt { margin: 5px 0 0; font-size: 12.5px; line-height: 1.7; color: var(--fg); white-space: pre-wrap; word-break: break-word; }
.cm-cmt .head .del { margin-left: auto; border: 0; background: none; color: var(--muted-2); font-size: 11px; cursor: pointer; }
.cm-cmt .head .del:hover { color: var(--danger); }

.cm-cmt-form { padding: 14px 16px; border-top: 1px solid var(--border); background: var(--surface-2); }
.cm-cmt-form textarea {
  width: 100%; min-height: 76px; padding: 9px 11px; resize: vertical;
  font: inherit; font-size: 12.5px; line-height: 1.7; color: var(--fg);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm); outline: none;
}
.cm-cmt-form textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(242, 169, 59, .16); }
.cm-cmt-row { display: flex; align-items: center; gap: 10px; margin-top: 9px; }
.cm-cmt-row .help { margin-right: auto; }

/* ---------------------------------------------------------------- 右栏 */
.cm-aside { position: sticky; top: 70px; display: flex; flex-direction: column; gap: 14px; }
.cm-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
.cm-panel-h {
  display: flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--fg-strong);
}
.cm-panel-h svg { width: 13px; height: 13px; color: var(--muted-2); }
.cm-panel-h .more {
  margin-left: auto; border: 0; background: none; cursor: pointer;
  font-size: 11px; color: var(--muted-2); padding: 0;
}
.cm-panel-h .more:hover { color: var(--brand); }

.cm-note { padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.cm-note:last-child { border-bottom: 0; }
.cm-note:hover { background: var(--surface-2); }
.cm-note .t {
  font-size: 11.5px; line-height: 1.6; color: var(--fg); word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cm-note:hover .t { color: var(--brand); }
.cm-note .d { margin-top: 4px; font-size: 10.5px; color: var(--muted-2); font-variant-numeric: tabular-nums; }

.cm-tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 14px; }
.cm-tags .none { font-size: 11px; color: var(--muted-2); }
.cm-tag {
  height: 22px; padding: 0 9px; border-radius: var(--r-pill);
  font-size: 11px; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border); cursor: pointer;
}
.cm-tag:hover { color: var(--brand); border-color: var(--brand); }
.cm-tag.on { color: var(--brand-ink); background: var(--brand); border-color: var(--brand); font-weight: 600; }

.cm-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 13px 14px; }
.cm-stats .it { text-align: center; }
.cm-stats .n { font-family: var(--font-mono); font-size: 15px; font-weight: 600; color: var(--fg-strong); }
.cm-stats .k { margin-top: 2px; font-size: 10px; color: var(--muted-2); }

/* ---------------------------------------------------------------- 弹窗 */
.mask {
  position: fixed; inset: 0; z-index: 60; display: none;
  background: rgba(8, 10, 14, .62); backdrop-filter: blur(2px);
  align-items: center; justify-content: center; padding: 20px;
}
.mask.on { display: flex; }
.modal {
  width: 100%; max-width: 560px; max-height: 88vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-lg); box-shadow: 0 24px 64px rgba(0, 0, 0, .5);
}
.modal header {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 16px;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--fg-strong);
}
.modal header .x {
  margin-left: auto; border: 0; background: transparent; cursor: pointer;
  font-size: 20px; line-height: 1; color: var(--muted); padding: 0 2px;
}
.modal header .x:hover { color: var(--fg); }
.modal .inner { padding: 16px; }
.modal textarea {
  width: 100%; min-height: 170px; padding: 9px 11px; resize: vertical;
  font: inherit; font-size: 13px; line-height: 1.7; color: var(--fg);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); outline: none;
}
.modal textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(242, 169, 59, .16); }
.modal .field .label .opt { color: var(--muted-2); font-weight: 400; }
.modal .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.modal .err { min-height: 16px; font-size: 11.5px; color: var(--danger); }

/* ---------------------------------------------------------------- toast */
#toast {
  position: fixed; left: 50%; bottom: 30px; z-index: 90;
  transform: translateX(-50%) translateY(14px);
  padding: 9px 16px; border-radius: var(--r-sm);
  background: rgba(24, 30, 39, .96); border: 1px solid var(--border-strong);
  color: var(--fg-strong); font-size: 12.5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  opacity: 0; pointer-events: none; transition: opacity .16s ease, transform .16s ease;
}
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------------------------------------------------------- 响应式 */
/* 1180 以下先**缩栏宽**而不是砍掉右栏：公告在社区里是"必须看得见"的内容，
   一上来就把它挪到信息流下面，等于让用户滚过整页才找到公告。 */
@media (max-width: 1180px) {
  .cm-body { grid-template-columns: 176px minmax(0, 1fr) 248px; gap: 14px; padding: 16px 16px 48px; }
  .cm-aside { gap: 12px; }
}
@media (max-width: 1040px) {
  .cm-body { grid-template-columns: 176px minmax(0, 1fr); }
  .cm-aside {
    position: static; grid-column: 1 / -1;
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
  }
}
@media (max-width: 820px) {
  .cm-body { grid-template-columns: 1fr; padding: 12px 12px 44px; gap: 12px; }
  .cm-side { position: static; flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .cm-side .side-cap,
  .cm-side .cm-side-foot { display: none; }
  .cm-me { width: 100%; padding-bottom: 10px; }
  /* 分类按钮装在一个 div 里：不把它也变成换行 flex，7 个分类会竖着叠成一列，
     把信息流推到首屏之外（实测踩到）。 */
  #cats { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
  .cm-side button.side-item {
    width: auto; height: 30px; padding: 0 10px;
    border: 1px solid var(--border); border-radius: var(--r-pill);
  }
  .cm-side button.side-item.on { border-color: var(--brand); }
  .cm-cnt { display: none; }
  .cm-aside { grid-template-columns: 1fr; }
  .cm-search { width: 140px; }
  .cm-who b { display: none; }
  .cm-who { padding: 0 5px; }
  .cm-composer .cm-select { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cm-post, .cm-search input, #toast { transition: none; }
}
