/*
 * 커뮤니티 — 목록(게시판 표)·글(본문/첨부/댓글을 각각 상자로)·글쓰기·첨부 고르기.
 * 화면 양옆은 조금만 띄우고(최대 880px), 상자마다 머리줄로 구역을 나눈다.
 */
#communityRoot { max-width: 880px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }

.cm-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.cm-head h2 { margin: 0; }
.cm-sub { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.cm-head .primary { flex: none; }
.cm-back { align-self: flex-start; }

.cm-error {
  padding: 10px 12px; border-radius: 10px;
  background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; font-size: 14px; font-weight: 600;
}
.cm-empty { padding: 28px 12px; text-align: center; color: var(--muted); font-size: 14px; }
.cm-quiet { padding: 6px 0; color: var(--muted); font-size: 13px; list-style: none; }
.cm-more { display: flex; justify-content: center; }

/* 상자 — 머리줄(구역 이름) + 본문 */
.cm-box { border: 1px solid var(--line); border-radius: 14px; background: #fff; overflow: hidden; }
.cm-box-head {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; margin: 0;
  padding: 10px 16px; background: #f6f8fb; border-bottom: 1px solid var(--line);
  font-size: 14px; font-weight: 800; color: #1f2937;
}
.cm-box-count { color: var(--primary); }
.cm-box-hint { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--muted); }
.cm-box-body { padding: 12px 16px 14px; }

/* 목록 위 — 검색 | 전체 개수·정렬·쪽당 글 수 */
.cm-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px; }
.cm-search { display: flex; align-items: center; gap: 6px; flex: 1 1 320px; min-width: 0; }
.cm-search select { flex: none; width: auto; }
.cm-search input { flex: 1; min-width: 0; max-width: 260px; }
.cm-view-opts { display: flex; align-items: center; gap: 6px; }
.cm-view-opts select { width: auto; }
.cm-total { font-size: 13px; color: var(--muted); margin-right: 4px; white-space: nowrap; }
.cm-toolbar select, .cm-toolbar input { height: 34px; padding-top: 0; padding-bottom: 0; font-size: 13px; }

/* 쪽 번호 */
.cm-pager { display: flex; justify-content: center; align-items: center; gap: 4px; flex-wrap: wrap; }
.cm-page {
  min-width: 32px; height: 32px; padding: 0 8px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: #344054; font-size: 13px; font-weight: 600; cursor: pointer;
}
.cm-page:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.cm-page.is-current { background: var(--primary); border-color: var(--primary); color: #fff; }
.cm-page:disabled { opacity: 0.4; cursor: default; }

/* 목록 — 제목 | 글쓴이 | 날짜 | 조회 | 추천 | 다운로드 */
.cm-board-head, .cm-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 100px 80px 40px 40px 56px; align-items: center; gap: 8px;
  padding: 0 16px;
}
.cm-board-head {
  height: 36px; background: #f6f8fb; border-bottom: 1px solid var(--line);
  font-size: 12px; font-weight: 800; color: var(--muted);
}
.cm-board-head .cm-cell-title { text-align: center; }
.cm-row {
  width: 100%; min-height: 48px; padding-top: 8px; padding-bottom: 8px;
  border: none; border-bottom: 1px solid #eef2f7; border-radius: 0;
  background: #fff; text-align: left; cursor: pointer; font: inherit; color: inherit;
}
.cm-row:last-child { border-bottom: none; }
.cm-row:hover, .cm-row:focus-visible { background: #f5f9ff; }
.cm-cell-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cm-cell-author, .cm-cell-date, .cm-cell-num { font-size: 13px; color: #475467; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-row-title { font-size: 14px; font-weight: 600; color: #111827; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.cm-row:hover .cm-row-title { color: var(--primary); }
.cm-row-comments { flex: none; color: var(--primary); font-size: 12px; font-weight: 700; }

.cm-badge {
  flex: none; padding: 0 6px; border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 18px;
  border: 1px solid var(--line); background: #fff; color: #344054;
}
.cm-badge-folder { border-color: #fde68a; background: #fffbeb; color: #92400e; }
.cm-badge-card { border-color: #bfdbfe; background: #eff6ff; color: #1d4ed8; }

/* 글 본문 */
.cm-post-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.cm-post-title { margin: 0 0 6px; font-size: 20px; line-height: 1.35; word-break: break-word; }
.cm-post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 13px; color: var(--muted); }
.cm-post-meta strong { color: #344054; }
.cm-post-delete { margin-left: auto; }
.cm-post-body { padding: 18px 18px 6px; white-space: pre-wrap; word-break: break-word; line-height: 1.7; font-size: 15px; }

.link-btn {
  padding: 0; border: none; background: none; color: var(--muted); font-size: 12px; font-weight: 600;
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:hover { color: #b91c1c; }

/* 첨부 — 게시물 안에서 강조된 구역 */
.cm-attach-zone {
  margin: 6px 18px 18px; padding: 12px; border-radius: 12px;
  background: #f5f9ff; border: 1px solid #cfe0fb;
}

/* 본문과 첨부 사이 — 추천 */
.cm-post-like { display: flex; justify-content: center; padding: 14px 18px 16px; }
.cm-post-like:last-child { padding-bottom: 22px; }
.cm-like {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px; border-radius: 999px;
  border: 1.5px solid var(--line); background: #fff; color: #344054; font-size: 14px; font-weight: 700; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.cm-like:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.cm-like.is-on { background: #eff6ff; border-color: var(--primary); color: var(--primary); }
.cm-like:disabled { cursor: default; opacity: 0.6; }
.cm-like-count { font-size: 15px; }

/* 게시물과 댓글 사이를 조금 더 띄운다 */
.cm-post + .cm-comments { margin-top: 12px; }

/* 이전 글·다음 글 */
.cm-neighbors { display: flex; flex-direction: column; }
.cm-neighbor {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 11px 16px; min-height: 44px;
  border: none; border-bottom: 1px solid #eef2f7; border-radius: 0; background: #fff;
  text-align: left; font: inherit; color: inherit; cursor: pointer;
}
.cm-neighbor:last-child { border-bottom: none; }
button.cm-neighbor:hover, button.cm-neighbor:focus-visible { background: #f5f9ff; }
button.cm-neighbor:hover .cm-neighbor-title { color: var(--primary); }
.cm-neighbor.is-none { cursor: default; }
.cm-neighbor.is-none .cm-neighbor-title { color: var(--muted); font-weight: 500; }
.cm-neighbor-label { flex: none; width: 52px; font-size: 12px; font-weight: 800; color: var(--muted); }
.cm-neighbor-title { min-width: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-attach-zone-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0 2px 10px; }
.cm-attach-zone-title { font-size: 14px; font-weight: 800; color: #1e3a8a; }
.cm-attach-zone-hint { margin-left: auto; font-size: 12px; color: #4b5d7a; }
.cm-items { display: flex; flex-direction: column; gap: 8px; }
.cm-item { border: 1px solid var(--line); border-radius: 10px; background: #fff; overflow: hidden; }
.cm-item-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 12px; }
.cm-kind { flex: none; padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: 800; line-height: 18px; }
.cm-kind-folder { background: #fffbeb; color: #92400e; }
.cm-kind-card { background: #eff6ff; color: #1d4ed8; }
.cm-item-title { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-item-sub { flex: none; font-size: 12px; color: var(--muted); }
.cm-item-count { margin-left: auto; flex: none; font-size: 12px; color: var(--muted); white-space: nowrap; }

/* 받기 버튼 — + 에서 받은 뒤 ✓ */
.cm-get {
  flex: none; width: 30px; height: 30px; padding: 0; border-radius: 50%;
  border: 1.5px solid var(--primary); background: #fff; color: var(--primary);
  font-size: 18px; font-weight: 700; line-height: 1; cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.cm-get:hover:not(:disabled) { background: var(--primary); color: #fff; }
.cm-get:active:not(:disabled) { transform: scale(0.92); }
.cm-get.is-done { border-color: #16a34a; background: #16a34a; color: #fff; font-size: 15px; }
.cm-get.is-done:hover:not(:disabled) { background: #15803d; }
.cm-get:disabled { opacity: 0.5; cursor: default; }

.cm-item-body { border-top: 1px solid #eef2f7; padding: 8px 12px 10px; font-size: 14px; background: #fcfdff; }
details.cm-item-body > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--primary); }
details.cm-item-body[open] > summary { margin-bottom: 6px; }

.cm-tree, .cm-tree ul { list-style: none; margin: 0; padding: 0; }
.cm-tree ul { padding-left: 16px; border-left: 1px dashed var(--line); margin-left: 6px; }
.cm-tree li { margin: 3px 0; }
.cm-tree-name { font-weight: 700; font-size: 13px; }

.cm-card > summary { cursor: pointer; font-size: 13px; padding: 2px 0; }
.cm-card-icon { color: var(--muted); margin-right: 4px; }
.cm-card-body { margin: 4px 0 8px; padding: 8px 10px; border-radius: 8px; background: #fff; border: 1px solid #eef2f7; }
.cm-card-label { font-size: 11px; font-weight: 800; color: var(--muted); margin-top: 4px; }
.cm-card-text { white-space: pre-wrap; word-break: break-word; line-height: 1.6; font-size: 13px; }
.cm-blank { background: #fef3c7; color: inherit; padding: 0 2px; border-radius: 3px; font-weight: 700; }

/* 댓글 */
.cm-comment-list { list-style: none; margin: 0 0 10px; padding: 0; }
.cm-comment { padding: 9px 0; border-bottom: 1px solid #eef2f7; }
.cm-comment:first-child { padding-top: 0; }
.cm-comment-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.cm-comment-meta strong { color: #344054; font-size: 13px; }
.cm-comment-meta .link-btn { margin-left: auto; }
.cm-comment-body { margin-top: 3px; white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 1.6; }
.cm-comment-form { display: flex; gap: 8px; align-items: flex-end; margin-top: 4px; }
.cm-comment-form textarea { flex: 1; min-width: 0; resize: vertical; }

/* 글쓰기 */
.cm-write .cm-box-head { font-size: 15px; }
.cm-write .cm-box-body { display: flex; flex-direction: column; gap: 14px; padding: 16px 18px 18px; }
.cm-field { display: flex; flex-direction: column; gap: 5px; }
.cm-field label { font-weight: 700; font-size: 14px; }
.cm-field-hint { margin: 0; font-size: 12px; color: var(--muted); }
.cm-write textarea { resize: vertical; min-height: 130px; }
.cm-attach-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cm-attach-list { list-style: none; margin: 2px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.cm-attach-row { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fcfdff; }
.cm-attach-title { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-attach-row .link-btn { margin-left: auto; }
.cm-write-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }

/* 첨부 고르기 */
.cm-picker { width: min(520px, 94vw); max-width: 520px; display: flex; flex-direction: column; gap: 8px; max-height: 86vh; }
.cm-picker h3 { margin: 0; }
.cm-pick-tree { overflow: auto; min-height: 160px; max-height: 52vh; border: 1px solid var(--line); border-radius: 10px; padding: 6px 4px; }
.cm-pick-row {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px calc(6px + var(--depth, 0) * 18px);
  border-radius: 6px; font-size: 14px; cursor: pointer;
}
.cm-pick-row:hover { background: var(--soft); }
.cm-pick-row span:nth-of-type(1) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-pick-row .caption { margin-left: auto; flex: none; }
.cm-pick-folder { font-weight: 700; }
.cm-pick-folder.is-empty { color: var(--muted); font-weight: 600; cursor: default; }
.cm-pick-folder.is-empty:hover { background: none; }
.cm-pick-row input:disabled + span { color: var(--muted); }
.cm-pick-group { margin: 8px 6px 2px; font-size: 12px; font-weight: 800; color: var(--muted); }
.cm-pick-actions { margin-top: 4px; }

@media (max-width: 640px) {
  .cm-board-head { display: none; }
  .cm-row {
    display: flex; flex-wrap: wrap; gap: 2px 10px; padding: 10px 12px;
  }
  .cm-row .cm-cell-title { width: 100%; }
  .cm-row .cm-cell-author, .cm-row .cm-cell-date, .cm-row .cm-cell-num { text-align: left; font-size: 12px; }
  .cm-row .cm-cell-views::before { content: "조회 "; }
  .cm-row .cm-cell-likes::before { content: "추천 "; }
  .cm-row .cm-cell-downloads::before { content: "다운로드 "; }
  .cm-box-hint, .cm-attach-zone-hint { margin-left: 0; width: 100%; }
  .cm-attach-zone { margin: 0 12px 14px; padding: 10px; }
  .cm-search input { max-width: none; }
  .cm-view-opts { width: 100%; justify-content: flex-end; }
  .cm-total { margin-right: auto; }
  .cm-item-head { flex-wrap: wrap; }
  .cm-item-sub { order: 3; width: 100%; }
  .cm-post-title { font-size: 18px; }
}
