/* Pantip-inspired Collector Community, styled in ThaiAmulets's charcoal & brass Luxe language. */
.comm-page { padding-bottom: 72px; }

/* Board header */
.comm-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  margin-bottom: 22px;
}
.comm-head h1 { font-size: clamp(1.75rem, 3.6vw, 2.5rem); margin: 0; }
.comm-head p { color: var(--ink-2); margin: 6px 0 0; max-width: 58ch; font-size: .95rem; }
.comm-head-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Pantip-style room bar */
.comm-rooms {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid #ffffff20;
  scrollbar-width: thin;
}
.comm-room-btn {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid #ffffff26;
  background: transparent;
  color: var(--ink-2);
  font: 500 .88rem/1.2 var(--body);
  cursor: pointer;
  transition: border-color .16s ease, color .16s ease, background .16s ease;
}
.comm-room-btn:hover { color: var(--ink); border-color: #e0b56c80; }
.comm-room-btn[aria-pressed="true"] {
  background: #e0b56c1f;
  border-color: var(--jade);
  color: var(--jade);
  font-weight: 700;
}

/* Toolbar: sort tabs + kind select + search */
.comm-toolbar {
  display: grid;
  grid-template-columns: auto auto minmax(180px, 1fr);
  gap: 12px 16px;
  align-items: center;
  margin-bottom: 18px;
}
.comm-tabs {
  display: inline-flex;
  border: 1px solid #ffffff26;
  border-radius: 6px;
  overflow: hidden;
}
.comm-tab {
  min-height: 40px;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: 500 .85rem/1.2 var(--body);
  cursor: pointer;
  border-right: 1px solid #ffffff1a;
}
.comm-tab:last-child { border-right: 0; }
.comm-tab:hover { color: var(--ink); background: #ffffff08; }
.comm-tab[aria-pressed="true"] {
  background: var(--jade);
  color: #15130e;
  font-weight: 700;
}
.comm-kind-select {
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #ffffff26;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: .85rem;
}
.comm-search-wrap {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ffffff38;
  gap: 8px;
}
.comm-search-wrap input {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 8px 4px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: .92rem;
}
.comm-search-wrap input::placeholder { color: var(--ink-2); opacity: .85; }
.comm-search-clear {
  background: transparent;
  border: 0;
  color: var(--ink-2);
  cursor: pointer;
  min-height: 36px;
  padding: 4px 8px;
  font-size: .8rem;
}
.comm-search-clear:hover { color: var(--jade); }

.comm-active-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: .85rem;
  color: var(--ink-2);
}
.comm-active-filter button {
  background: transparent;
  border: 1px solid #ffffff30;
  border-radius: 999px;
  color: var(--jade);
  padding: 4px 12px;
  font-size: .8rem;
  cursor: pointer;
}

/* Pantip-style dense, scannable thread list */
.comm-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid #e0b56c40;
}
.comm-row {
  border-bottom: 1px solid #ffffff1c;
  transition: background .16s ease;
}
.comm-row:hover { background: #ffffff06; }
.comm-row.is-pinned { background: #e0b56c0a; }
.comm-row-link {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 14px 16px;
  align-items: center;
  padding: 15px 10px;
  text-decoration: none;
  color: inherit;
}
.comm-thumb {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  overflow: hidden;
  background: #1f211f;
  border: 1px solid #ffffff1a;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--jade);
  flex-shrink: 0;
}
.comm-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.comm-thumb svg { width: 22px; height: 22px; }

.comm-row-main { min-width: 0; display: grid; gap: 5px; }
.comm-row-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  font-size: .74rem;
}
.comm-kind-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 700;
  font-size: .72rem;
  letter-spacing: .01em;
}
.comm-kind-question { background: #e0b56c24; color: #f0cd88; border: 1px solid #e0b56c55; }
.comm-kind-discussion { background: #7aa7c724; color: #b5d5ec; border: 1px solid #7aa7c755; }
.comm-kind-review { background: #74b48624; color: #b0e0bd; border: 1px solid #74b48655; }
.comm-kind-showcase { background: #c9886624; color: #f0c2a8; border: 1px solid #c9886655; }

.comm-badge-pin {
  background: #e0b56c;
  color: #15130e;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: .7rem;
}
.comm-badge-lock {
  background: #ffffff18;
  color: var(--ink-2);
  padding: 2px 7px;
  border-radius: 3px;
  font-size: .7rem;
}
.comm-badge-hidden {
  background: #8f2d2d44;
  color: #f4b2b2;
  border: 1px solid #c94a4a66;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: .7rem;
}
.comm-badge-official {
  background: #e0b56c26;
  color: var(--jade);
  border: 1px solid #e0b56c66;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: .68rem;
  font-weight: 700;
}
.comm-badge-op {
  background: #ffffff16;
  color: var(--ink);
  border: 1px solid #ffffff30;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: .68rem;
  font-weight: 700;
}
.comm-room-label { color: var(--ink-2); }

.comm-row-title {
  margin: 0;
  font-size: 1.04rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.comm-row-link:hover .comm-row-title { color: var(--jade); }

.comm-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.comm-tag {
  font-size: .72rem;
  color: var(--ink-2);
  background: #ffffff0c;
  border: 1px solid #ffffff1a;
  border-radius: 3px;
  padding: 1px 7px;
}
button.comm-tag {
  cursor: pointer;
  font-family: var(--body);
}
button.comm-tag:hover { border-color: var(--jade); color: var(--jade); }

.comm-row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: .78rem;
  color: var(--ink-2);
}

.comm-row-stats {
  display: flex;
  gap: 14px;
  align-items: center;
  color: var(--ink-2);
  font-size: .82rem;
  flex-shrink: 0;
}
.comm-stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 40px;
  justify-content: flex-end;
}
.comm-stat svg { width: 15px; height: 15px; opacity: .8; }
.comm-stat.has-count { color: var(--ink); }

.comm-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--ink-2);
  border-bottom: 1px solid #ffffff18;
}
.comm-empty h2 { font-size: 1.15rem; color: var(--ink); margin: 0 0 8px; }
.comm-empty p { margin: 0 auto 18px; max-width: 46ch; font-size: .92rem; }
.comm-more-wrap { display: flex; justify-content: center; margin-top: 22px; }

/* Thread Detail View (Pantip OP + numbered comments + sub-replies) */
.comm-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--jade);
  text-decoration: none;
  font-size: .9rem;
  margin-bottom: 18px;
  min-height: 36px;
}
.comm-back:hover { text-decoration: underline; }

.comm-op {
  background: #1b1d1b;
  border: 1px solid #e0b56c44;
  border-radius: 8px;
  padding: 24px 26px;
  margin-bottom: 24px;
}
.comm-op-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.comm-op-title {
  font-size: clamp(1.35rem, 2.8vw, 1.95rem);
  line-height: 1.28;
  margin: 0 0 12px;
  overflow-wrap: anywhere;
}
.comm-op-body {
  font-size: 1rem;
  line-height: 1.72;
  color: #eeede8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 18px 0;
}
.comm-catalogue-photo { margin: 0; max-width: 30rem; white-space: normal; }
.comm-catalogue-photo img { display: block; width: 100%; height: clamp(13rem, 42vw, 21rem); object-fit: contain; }
.comm-catalogue-photo figcaption { margin-top: .5rem; font-size: .9rem; }
.comm-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin: 16px 0;
}
.comm-gallery button {
  padding: 0;
  border: 1px solid #ffffff22;
  border-radius: 6px;
  overflow: hidden;
  background: #121413;
  cursor: pointer;
  aspect-ratio: 4 / 3;
}
.comm-gallery button:hover { border-color: var(--jade); }
.comm-gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }

.comm-op-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 18px;
  padding-top: 16px;
  border-top: 1px solid #ffffff1c;
}
.comm-author-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: .85rem;
  color: var(--ink-2);
}
.comm-author-line strong { color: var(--ink); }

.comm-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.comm-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 12px;
  border-radius: 5px;
  border: 1px solid #ffffff28;
  background: transparent;
  color: var(--ink-2);
  font: 500 .84rem/1.2 var(--body);
  cursor: pointer;
}
.comm-action-btn:hover { color: var(--ink); border-color: #ffffff50; }
.comm-action-btn.is-voted {
  background: #e0b56c24;
  border-color: var(--jade);
  color: var(--jade);
  font-weight: 700;
}
.comm-action-btn.is-danger:hover { border-color: #d96b6b; color: #f4b2b2; }
.comm-action-btn svg { width: 15px; height: 15px; }

.comm-mod-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed #e0b56c40;
  font-size: .8rem;
  color: var(--jade);
}

/* Comments & nested replies */
.comm-comments-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 26px 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e0b56c40;
}
.comm-comments-head h2 { font-size: 1.15rem; margin: 0; }

.comm-comment-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.comm-comment {
  background: #191b19;
  border: 1px solid #ffffff1a;
  border-radius: 7px;
  padding: 16px 18px;
}
.comm-comment.is-hidden-item { opacity: .68; border-style: dashed; border-color: #c94a4a66; }
.comm-comment-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  font-size: .8rem;
  color: var(--ink-2);
}
.comm-comment-num {
  color: var(--jade);
  font-weight: 700;
  font-size: .82rem;
}
.comm-comment-body {
  font-size: .95rem;
  line-height: 1.65;
  color: #eeede8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0 0 12px;
}
.comm-comment-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid #ffffff12;
}

.comm-replies {
  list-style: none;
  margin: 14px 0 0;
  padding: 0 0 0 16px;
  border-left: 2px solid #e0b56c40;
  display: grid;
  gap: 10px;
}
.comm-reply {
  background: #141614;
  border: 1px solid #ffffff12;
  border-radius: 6px;
  padding: 12px 14px;
}

/* Composer (comment & inline reply) */
.comm-composer {
  background: #1b1d1b;
  border: 1px solid #ffffff22;
  border-radius: 8px;
  padding: 18px 20px;
  margin-top: 22px;
}
.comm-composer h3 { font-size: 1rem; margin: 0 0 12px; }
.comm-composer textarea,
.comm-dialog textarea,
.comm-dialog input[type="text"],
.comm-dialog select {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 14px;
  border: 1px solid #ffffff30;
  border-radius: 5px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: .95rem;
}
.comm-composer textarea { min-height: 100px; resize: vertical; }
.comm-composer-inline { margin-top: 12px; padding: 14px; background: #141614; }
.comm-composer-inline textarea { min-height: 76px; }
.comm-composer-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}
.comm-upload-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 12px;
  border: 1px dashed #ffffff3a;
  border-radius: 5px;
  color: var(--ink-2);
  font-size: .84rem;
  cursor: pointer;
}
.comm-upload-btn:hover { border-color: var(--jade); color: var(--jade); }
.comm-upload-btn:focus-within { outline: 2px solid var(--jade); outline-offset: 3px; }
.comm-upload-btn input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.comm-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.comm-preview-item {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid #ffffff28;
}
.comm-preview-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.comm-preview-item button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  background: #121413d9;
  color: var(--ink);
  font-size: .78rem;
  line-height: 1;
  cursor: pointer;
}

.comm-form-err { color: #f4a4a4; font-size: .86rem; margin: 8px 0 0; }
.comm-notice {
  padding: 16px 18px;
  border-radius: 6px;
  border: 1px solid #ffffff22;
  background: #1a1c1a;
  color: var(--ink-2);
  font-size: .92rem;
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Native dialogs: New/Edit Topic & Photo Lightbox */
.comm-dialog {
  width: min(640px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid #e0b56c55;
  border-radius: 10px;
  background: #181a18;
  color: var(--ink);
  overflow: auto;
}
.comm-dialog::backdrop { background: #000000b8; }
.comm-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid #ffffff1c;
}
.comm-dialog-head h2 { margin: 0; font-size: 1.2rem; }
.comm-dialog-close {
  background: transparent;
  border: 1px solid #ffffff26;
  border-radius: 5px;
  color: var(--ink);
  min-width: 36px;
  min-height: 36px;
  cursor: pointer;
  font-size: 1rem;
}
.comm-dialog-body { padding: 18px 22px 22px; display: grid; gap: 14px; }
.comm-field { display: grid; gap: 6px; }
.comm-field label { font-size: .85rem; color: var(--ink-2); font-weight: 600; }
.comm-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.comm-dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 6px;
}

.comm-lightbox {
  width: min(920px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 14px;
  border: 1px solid #ffffff28;
  border-radius: 8px;
  background: #111311;
  color: var(--ink);
}
.comm-lightbox::backdrop { background: #000000d9; }
.comm-lightbox img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 104px);
  margin: 0 auto;
  object-fit: contain;
}
.comm-lightbox-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

/* Homepage live community widget refinements */
.sf-comm-tabs {
  display: flex;
  gap: 6px;
  margin: 8px 0 12px;
}
.sf-comm-tab {
  min-height: 34px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid #ffffff26;
  background: transparent;
  color: var(--ink-2);
  font: 500 .8rem/1.2 var(--body);
  cursor: pointer;
}
.sf-comm-tab[aria-pressed="true"] {
  background: var(--jade);
  border-color: var(--jade);
  color: #15130e;
  font-weight: 700;
}
.sf-comm-home-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: .74rem;
  color: var(--ink-2);
  margin-top: 3px;
}

@media (max-width: 760px) {
  .comm-toolbar { grid-template-columns: 1fr; }
  .comm-tabs { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); }
  .comm-row-link {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 10px 12px;
    padding: 13px 4px;
  }
  .comm-thumb { width: 48px; height: 48px; }
  .comm-row-stats {
    grid-column: 2;
    justify-content: flex-start;
    margin-top: 2px;
  }
  .comm-stat { justify-content: flex-start; min-width: 0; }
  .comm-op { padding: 18px 16px; }
  .comm-field-row { grid-template-columns: 1fr; }
  .comm-replies { padding-left: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .comm-room-btn, .comm-row { transition: none; }
}

.comm-preview-item {
  width: 96px;
  height: 96px;
  background: radial-gradient(ellipse 80% 72% at 50% 52%, #3a3122 0%, #1d1b17 62%, #131412 100%);
}
.comm-preview-item .comm-bg-btn {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 3px;
  width: auto;
  height: auto;
  min-height: 22px;
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid #e0b56c88;
  background: #141513e6;
  color: var(--jade);
  font: 600 .68rem/1.1 var(--body);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.comm-preview-item .comm-bg-btn:hover { background: var(--jade); color: #15130e; }
.comm-preview-item .comm-bg-btn:disabled { opacity: .65; cursor: wait; }
