.comments-widget {
  margin: 3rem 0 2rem;
  padding: 1.5rem;
  background: #fafafa;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", sans-serif;
}
details.comments-widget.cw-compact {
  margin: 1rem 0 1.5rem;
  padding: 0;
  background: transparent;
  border: 0;
}
details.comments-widget.cw-compact > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.8rem;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  font-size: 0.8rem;
  color: #4b5563;
  user-select: none;
}
details.comments-widget.cw-compact > summary::-webkit-details-marker { display: none; }
details.comments-widget.cw-compact > summary:hover { background: #e5e7eb; }
details.comments-widget.cw-compact[open] > summary {
  background: #111;
  color: #fff;
  border-color: #111;
}
details.comments-widget.cw-compact[open] > summary .cw-count { background: #fff; color: #111; }
details.comments-widget.cw-compact > .cw-body {
  margin-top: 0.75rem;
  padding: 1rem;
  background: #fafafa;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}
.comments-widget h3 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  color: #111;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.comments-widget h3 .cw-count {
  display: inline-block;
  min-width: 1.5rem;
  padding: 0.1rem 0.5rem;
  background: #111;
  color: #fff;
  border-radius: 999px;
  font-size: 0.75rem;
  text-align: center;
  font-weight: 600;
}

.cw-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.cw-empty {
  padding: 1.5rem;
  text-align: center;
  color: #9ca3af;
  font-size: 0.9rem;
  background: #fff;
  border-radius: 8px;
  border: 1px dashed #e5e7eb;
}
.cw-item {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.75rem 1rem;
}
.cw-item-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
}
.cw-name {
  font-weight: 600;
  color: #111;
}
.cw-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.cw-time {
  color: #9ca3af;
  font-size: 0.75rem;
}
.cw-delete {
  background: transparent;
  border: 1px solid #e5e7eb;
  color: #9ca3af;
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
  font-size: 0.7rem;
  cursor: pointer;
  font-family: inherit;
}
.cw-delete:hover {
  color: #dc2626;
  border-color: #dc2626;
}
.cw-content {
  color: #374151;
  font-size: 0.92rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.cw-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.cw-form input,
.cw-form textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  background: #fff;
  box-sizing: border-box;
}
.cw-form input:focus,
.cw-form textarea:focus {
  outline: none;
  border-color: #111;
}
.cw-form textarea {
  min-height: 80px;
  resize: vertical;
}
.cw-form-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.cw-hint {
  font-size: 0.75rem;
  color: #9ca3af;
}
.cw-submit {
  padding: 0.55rem 1.25rem;
  background: #111;
  color: #fff;
  border: 0;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.cw-submit:hover { background: #333; }
.cw-submit:disabled { background: #9ca3af; cursor: not-allowed; }
.cw-error {
  color: #dc2626;
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

/* 첨부: 폼 영역 */
.cw-attach {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.cw-filepick {
  padding: 0.45rem 0.8rem;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  color: #374151;
}
.cw-filepick:hover { border-color: #111; color: #111; }
.cw-attach-info {
  font-size: 0.72rem;
  color: #9ca3af;
}
.cw-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.cw-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.55rem;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  font-size: 0.75rem;
  color: #374151;
  max-width: 100%;
}
.cw-chip-name {
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cw-chip-size { color: #9ca3af; font-size: 0.7rem; }
.cw-chip-x {
  background: transparent;
  border: 0;
  color: #6b7280;
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0 0.15rem;
  line-height: 1;
  font-family: inherit;
}
.cw-chip-x:hover { color: #dc2626; }

/* 첨부: 댓글 출력 영역 */
.cw-attachments {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.cw-att-images {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.cw-att-image {
  display: block;
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  background: #fafafa;
}
.cw-att-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cw-att-files {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.cw-att-file {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 0.8rem;
  color: #374151;
  text-decoration: none;
  max-width: 100%;
}
.cw-att-file:hover { background: #f3f4f6; color: #111; }
.cw-att-name {
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cw-att-size { color: #9ca3af; font-size: 0.72rem; margin-left: auto; }

@media (prefers-color-scheme: dark) {
  .comments-widget {
    background: #1a1a1a;
    border-color: #2a2a2a;
  }
  .comments-widget h3 { color: #f3f4f6; }
  .comments-widget h3 .cw-count { background: #f3f4f6; color: #111; }
  .cw-empty {
    background: #111;
    color: #6b7280;
    border-color: #2a2a2a;
  }
  .cw-item {
    background: #111;
    border-color: #2a2a2a;
  }
  .cw-name { color: #f3f4f6; }
  .cw-content { color: #d1d5db; }
  .cw-form input,
  .cw-form textarea {
    background: #111;
    border-color: #2a2a2a;
    color: #f3f4f6;
  }
  .cw-form input:focus,
  .cw-form textarea:focus { border-color: #f3f4f6; }
  .cw-submit { background: #f3f4f6; color: #111; }
  .cw-submit:hover { background: #fff; }
  .cw-delete { border-color: #2a2a2a; color: #6b7280; }
  .cw-delete:hover { color: #ef4444; border-color: #ef4444; }
  .cw-filepick { background: #111; border-color: #2a2a2a; color: #d1d5db; }
  .cw-filepick:hover { border-color: #f3f4f6; color: #f3f4f6; }
  .cw-chip { background: #1a1a1a; border-color: #2a2a2a; color: #d1d5db; }
  .cw-chip-size, .cw-chip-x { color: #6b7280; }
  .cw-att-image { background: #111; border-color: #2a2a2a; }
  .cw-att-file { background: #111; border-color: #2a2a2a; color: #d1d5db; }
  .cw-att-file:hover { background: #1a1a1a; color: #f3f4f6; }
  .cw-att-size { color: #6b7280; }
  details.comments-widget.cw-compact > summary {
    background: #1a1a1a;
    border-color: #2a2a2a;
    color: #d1d5db;
  }
  details.comments-widget.cw-compact > summary:hover { background: #222; }
  details.comments-widget.cw-compact[open] > summary {
    background: #f3f4f6;
    color: #111;
    border-color: #f3f4f6;
  }
  details.comments-widget.cw-compact[open] > summary .cw-count { background: #111; color: #fff; }
  details.comments-widget.cw-compact > .cw-body {
    background: #1a1a1a;
    border-color: #2a2a2a;
  }
}
