/* HM 이모티콘 피커 */

:root {
  --hm-pc-emo-size: 26px;
}

.hm_emo_wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.hm_emo_trigger_row {
  display: inline-flex;
  align-items: center;
  gap: 0;
}
.hm_emo_label {
  font-size: 12px;
  font-weight: 400;
  color: #9ca3af;
  line-height: 1;
  white-space: nowrap;
  user-select: none;
  pointer-events: none;
}

.hm_emo_layer {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 360px;
  max-width: calc(100vw - 32px);
  max-height: 260px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.13);
  padding: 0;
  overflow: hidden;
  overscroll-behavior: contain;
  z-index: 9999;
  box-sizing: border-box;
}
.hm_emo_layer.is-open { display: block !important; }

.hm_emo_tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px 6px 0;
  border-bottom: 1px solid #f0f0f0;
  overflow-x: auto;
  scrollbar-width: none;
}
.hm_emo_tabs::-webkit-scrollbar { display: none; }
.hm_emo_tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 5px 7px;
  margin: 0 0 -1px;
  font-size: 12px;
  color: #9ca3af;
  cursor: pointer;
  white-space: nowrap;
}
.hm_emo_tab.is-active {
  color: #333;
  border-bottom-color: #555;
  font-weight: 600;
}

.hm_emo_grids {
  height: 160px;
  overflow-y: auto;
  padding: 8px;
  box-sizing: border-box;
}
.hm_emo_grids::-webkit-scrollbar { width: 4px; }
.hm_emo_grids::-webkit-scrollbar-track { background: transparent; }
.hm_emo_grids::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, .25);
  border-radius: 2px;
}

.hm_emo_grid {
  display: none;
  grid-template-columns: repeat(8, 40px);
  gap: 2px;
  width: max-content;
}
.hm_emo_grid.is-active {
  display: grid;
}

.hm_emo_item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 3px;
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s;
  box-sizing: border-box;
}
.hm_emo_item:hover { background: #f3f4f6; }
.hm_emo_item img {
  width: var(--hm-pc-emo-size, 26px);
  height: var(--hm-pc-emo-size, 26px);
  display: block;
  object-fit: contain;
  pointer-events: none;
}
.hm_emo_empty {
  margin: 0;
  padding: 10px;
  color: #999;
  font-size: 12px;
}

.hm_emo_trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  height: 32px;
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s;
  padding: 0 3px 0 8px;
  margin-left: -4px;
}
.hm_emo_trigger img {
  width: var(--hm-pc-emo-size, 26px);
  height: var(--hm-pc-emo-size, 26px);
  pointer-events: none;
}
.hm_emo_trigger:hover { background: #f3f4f6; }

.hm_emo_img {
  width: 28px !important;
  height: 28px !important;
  vertical-align: middle !important;
  display: inline !important;
  margin: 0 1px !important;
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_emo_label {
  color: var(--hm-text-sub, #a1a1a1);
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_emo_trigger {
  color: var(--hm-text-main, #e1e1e1);
  background: transparent;
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_emo_trigger:hover,
html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_emo_trigger:active {
  background: var(--hm-tap, rgba(255,255,255,.05));
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_emo_layer {
  background: var(--hm-bg-surface, #1e1e20);
  border-color: #3b4454;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.55);
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_vc_form_left .hm_emo_layer {
  border-color: #2f394a !important;
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_emo_tabs {
  border-bottom-color: var(--hm-border, #2c2c2e);
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_emo_tab {
  color: var(--hm-text-muted, #787878);
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_emo_tab.is-active {
  color: var(--hm-text-main, #e1e1e1);
  border-bottom-color: var(--hm-text-sub, #a1a1a1);
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_emo_grids::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_emo_item {
  color: var(--hm-text-main, #e1e1e1);
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_emo_item:hover,
html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_emo_item:active {
  background: var(--hm-tap, rgba(255,255,255,.05));
}

html[data-hm-theme="dark"] body:not(.hm-mobile) .hm_emo_empty {
  color: var(--hm-text-muted, #787878);
}

@media (max-width: 640px) {
  :root {
    --hm-mobile-emo-size: 26px;
  }
  .hm_emo_layer {
    width: min(308px, calc(100vw - 24px));
  }
  .hm_emo_grids {
    padding: 8px;
  }
  .hm_emo_grid {
    grid-template-columns: repeat(7, 40px);
  }
  .hm_emo_item img {
    width: var(--hm-mobile-emo-size, 26px);
    height: var(--hm-mobile-emo-size, 26px);
  }
}

/* 모바일 이모티콘 — 앱 토글 (OS prefers-color-scheme 대신 data-hm-theme) */
html[data-hm-theme="dark"] body.hm-mobile .hm_emo_label {
  color: var(--hm-text-sub, #A1A1A1);
}
html[data-hm-theme="dark"] body.hm-mobile .hm_emo_trigger {
  color: var(--hm-text-main, #E1E1E1);
  background: transparent;
}
html[data-hm-theme="dark"] body.hm-mobile .hm_emo_trigger:hover,
html[data-hm-theme="dark"] body.hm-mobile .hm_emo_trigger:active {
  background: var(--hm-tap, rgba(255,255,255,.05));
}
html[data-hm-theme="dark"] body.hm-mobile .hm_emo_layer {
  background: var(--hm-bg-surface, #1E1E20);
  border-color: var(--hm-card-border, rgba(255,255,255,.10));
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.55);
}
html[data-hm-theme="dark"] body.hm-mobile .hm_emo_tabs {
  border-bottom-color: var(--hm-border, #2C2C2E);
}
html[data-hm-theme="dark"] body.hm-mobile .hm_emo_tab {
  color: var(--hm-text-muted, #787878);
}
html[data-hm-theme="dark"] body.hm-mobile .hm_emo_tab.is-active {
  color: var(--hm-text-main, #E1E1E1);
  border-bottom-color: var(--hm-text-sub, #A1A1A1);
}
html[data-hm-theme="dark"] body.hm-mobile .hm_emo_grids::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
}
html[data-hm-theme="dark"] body.hm-mobile .hm_emo_item {
  color: var(--hm-text-main, #E1E1E1);
}
html[data-hm-theme="dark"] body.hm-mobile .hm_emo_item:hover,
html[data-hm-theme="dark"] body.hm-mobile .hm_emo_item:active {
  background: var(--hm-tap, rgba(255,255,255,.05));
}
html[data-hm-theme="dark"] body.hm-mobile .hm_emo_empty {
  color: var(--hm-text-muted, #787878);
}
