<!doctype html>
<html lang="en">
<meta charset="utf-8" />
<title>What do you think about “myperfumecenter“? | co·cc</title>

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="description" content="What do people really think? Discover public questions, opinions, and stories about people, celebrities, brands, and more. Search any name and join the conversation. Copy">
<meta name="keywords" content="what do people think about me, what are people saying about me, people opinions, public questions, ask questions, share opinions, name search, celebrity opinions, public discussions, reviews, personal stories, reputation, co.cc Copy">

<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">
<meta name="format-detection" content="telephone=no,email=no,address=no">

<meta name="google" content="notranslate">
<meta name="robots" content="index,follow">

<link rel="canonical" href="https://myperfumecenter.co.cc/post/90294563">
<meta name="theme-color" content="#ffffff">


<!-- Open Graph -->
<meta property="og:title" content="What do you think about “myperfumecenter“? | co·cc">
<meta property="og:description" content="What do people really think? Discover public questions, opinions, and stories about people, celebrities, brands, and more. Search any name and join the conversation. Copy">
<meta property="og:url" content="https://myperfumecenter.co.cc/post/90294563">
<meta property="og:image" content="https://short-img1.cc.cc/img/favicon-256.png">
<meta property="og:image:secure_url" content="https://short-img1.cc.cc/img/favicon-256.png">
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:type" content="profile">
<meta property="og:locale" content="en_US">
<meta property="og:site_name" content="co·cc">

<!-- Twitter Card -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="What do you think about “myperfumecenter“? | co·cc">
<meta name="twitter:description" content="What do people really think? Discover public questions, opinions, and stories about people, celebrities, brands, and more. Search any name and join the conversation. Copy">
<meta name="twitter:image" content="https://short-img1.cc.cc/img/favicon-256.png">
<meta name="twitter:image:alt" content="myperfumecenter | co·cc">
<meta name="twitter:url" content="https://myperfumecenter.co.cc/post/90294563">
<meta name="twitter:domain" content="co.cc">

<link rel="shortcut icon" href="https://short-img1.cc.cc/img/favicon-256.png">




<script src="https://short-img1.cc.cc/js/jquery.min.js"></script>

<!-- Bootstrap Css -->
<link href="https://short-img1.cc.cc/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" />

<!-- App Css 2025-08-20-->
<link href="https://short-img1.cc.cc/css/app.min.css" id="app-style" rel="stylesheet" type="text/css">

<!-- 모바일에서 상단 줄 생기는 현상 방지-->
<style>
@media (max-width: 767px) {
  .shape svg {
    margin-bottom: -2px;
  }
}
</style>

<style>
/* [우선순위 1] 최상위 뷰포트 및 레이아웃 박스 기준 정립 */
html {
  width: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

/* [우선순위 2] .container 상하·좌우 중앙 정렬 보장 */
.container {
  width: 100%;
  max-width: 480px;
  box-sizing: border-box;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 0 !important;
  padding-top: calc(64px + env(safe-area-inset-top));
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: center;
}



.landing-bg {
  background-color: #f1f0fe;
}

.write-fixed-width {
  width: 380px;
  min-width: 380px;
  max-width: 400px;
}
@media (max-width: 380px) {
  .write-fixed-width {
    width: 99%;
    min-width: auto;
    max-width: none;
  }
}

.card-fixed-width {
  width: 380px;
  min-width: 380px;
  max-width: 400px;
  border: 1px solid #e1e0fe;
  border-radius: 1.0rem;
}
@media (max-width: 576px) {
  .card-fixed-width {
    width: 98%;
    min-width: auto;
    max-width: none;
    border-radius: 1.0rem;
  }
}

.card-fixed-width img {
  display: block;
  width: 100%;
  background-color: #e9ecef;
}

.posting-text-color {
  color: #3d454e;
}

/* ===== 팝업 오버레이 및 모달 레이어 (평소 숨김, 클릭 시 표시) ===== */
#ccMsgOverlay,
#ccViewOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1040;
}

#ccMsgPopup,
#ccViewPopup {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.18);
  z-index: 1050;
  overflow: hidden;
}

#ccMsgPopup .popup-header-line,
#ccViewPopup .popup-header-line {
  position: relative;
  padding: 14px 40px 12px 16px;
  border-bottom: 1px solid #f0effa;
  font-weight: 700;
  font-size: 16px;
  color: #3d454e;
  text-align: center;
}

#ccMsgPopup .popup-btn-sm {
  width: 100%;
  height: 44px;
  font-weight: 700;
  margin-top: 10px;
}
</style>

<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-9T9CVW81BZ"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'G-9T9CVW81BZ');
</script>

<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-17432333679"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'AW-17432333679');
</script>

<script>
var ccPage = {
  slug: "myperfumecenter",
  name: "myperfumecenter"};
</script>
</head>

<body class="min-vh-100 landing-bg">
<div class="container landing-bg">







<!-- ===== 미등록 이름 페이지: 상단 (추가) ===== -->
<style>
/* ===== 상단 도메인 헤더 ===== */
.cc-top-domain{
        position:fixed;
        top:0;
        left:0;
        right:0;
        z-index:13;
        display:flex;
        align-items:center;
        justify-content:center;
        gap:8px;
        padding:calc(12px + env(safe-area-inset-top)) 60px 12px;
        background:rgba(241,240,254,.92);
        -webkit-backdrop-filter:blur(10px);
        backdrop-filter:blur(10px);
        border-bottom:1px solid #e1e0fe;
}

.cc-td-name{
        min-width:0;
        font-size:22px;
        font-weight:800;
        letter-spacing:-.4px;
        line-height:1.2;
        color:#766DF4;
        white-space:nowrap;
        overflow:hidden;
        text-overflow:ellipsis;
}

.cc-td-tld{
        color:#463DC9;
}

.cc-top-domain .cc-un-chip{
        margin:0;
        flex-shrink:0;
}

.cc-hd-btn{
        position:absolute;
        top:calc(50% + env(safe-area-inset-top)/2);
        transform:translateY(-50%);
        width:40px;
        height:40px;
        border:0;
        border-radius:50%;
        background:transparent;
        color:#766DF4;
        display:flex;
        align-items:center;
        justify-content:center;
        padding:0;
        cursor:pointer;
        -webkit-tap-highlight-color:transparent;
}

.cc-hd-btn:hover{
        background:#e9e7fd;
        color:#463DC9;
}

.cc-hd-btn svg{
        width:22px;
        height:22px;
}

.cc-hd-left{left:10px;}
.cc-hd-right{right:10px;}

/* ===== 질문 카드 위치 ===== */
.cc-q-wrap{
        margin-top:calc(72px + env(safe-area-inset-top));
}

/* ===== 질문 카드 ===== */
.cc-q-card{
        padding:22px 20px;
        text-align:left;
        background:#5B52E0 !important;
        border:0 !important;
        box-shadow:0 8px 24px rgba(91,82,224,.28);
}

/* 질문 제목 */
.cc-q-card .cc-q-title{
        font-size:24px;
        font-weight:800;
        line-height:1.25;
        letter-spacing:-.4px;
        color:#fff;
        margin:0 0 14px;
}

.cc-q-card .cc-q-title .cc-name{
        color:#FFD970;
}

/* 가입 안내 */
.cc-q-hint{
        display:flex;
        align-items:center;
        justify-content:flex-start;
        gap:5px;
        margin:-4px 0 10px 2px;
        font-size:13px;
        font-weight:600;
        color:#E9E7FD;
}

.cc-q-hint svg{
        width:14px;
        height:14px;
        opacity:.85;
        flex-shrink:0;
}

/* 글쓰기 버튼 */
.cc-q-card .cc-q-btn{
        position:relative;
        overflow:hidden;
        display:flex !important;
        align-items:center;
        justify-content:center;
        gap:8px;
        width:100%;
        min-height:52px;
        height:auto;
        padding:8px 16px;
        flex-direction:row;
        border:0;
        border-radius:999px;
        background:#fff;
        color:#5B52E0;
        font-size:17px;
        font-weight:700;
        line-height:1.2;
        box-shadow:0 6px 18px rgba(30,20,120,.28);
}

.cc-q-card .cc-q-btn:hover,
.cc-q-card .cc-q-btn:focus{
        background:#F1F0FE;
        color:#463DC9;
}

/* 버튼 글자 */
.cc-q-btn-main{
        font-size:16px;
        font-weight:700;
}

/* 버튼 반짝임 효과 */
.cc-q-card .cc-q-btn::after{
        content:"";
        position:absolute;
        top:0;
        left:-60%;
        width:40%;
        height:100%;
        background:linear-gradient(
                100deg,
                transparent,
                rgba(118,109,244,.18),
                transparent
        );
        animation:ccShine 3.6s ease-in-out 1.2s infinite;
}

@keyframes ccShine{
        0%{left:-60%}
        35%,100%{left:120%}
}

@media (prefers-reduced-motion:reduce){
        .cc-q-card .cc-q-btn::after{
                animation:none;
                display:none;
        }
}




@keyframes ccBlink {0%,100% {opacity:1} 50% {opacity:.25}}



@media (prefers-reduced-motion:reduce) {.cc-cloud-btn svg {animation:none;}}
.cc-un-av {width:120px;height:120px;border-radius:50%;border:2px dashed #b7b2f6;background:#fff;display:inline-flex;align-items:center;justify-content:center;font-size:40px;font-weight:700;color:#b7b2f6;letter-spacing:1px;}
.cc-un-chip {display:inline-block;margin-left:6px;padding:3px 10px;border-radius:999px;background:#fff4e5;color:#8a4b00;font-size:12px;font-weight:700;vertical-align:middle;}
.cc-q-card {padding:22px 20px;text-align:left;background:#5B52E0 !important;border:0 !important;box-shadow:0 8px 24px rgba(91,82,224,.28);}
.cc-q-title {font-size:24px;font-weight:800;line-height:1.25;letter-spacing:-.4px;color:#3d454e;margin:0 0 8px;}
.cc-q-sub {font-size:15px;line-height:1.5;color:#6c7280;margin-bottom:16px;}
.cc-q-btn {height:50px;font-size:16px;font-weight:700;display:flex !important;align-items:center;justify-content:center;}
.cc-q-card .cc-q-title {margin:0 0 8px;font-size:24px;font-weight:800;line-height:1.25;letter-spacing:-.4px;color:#fff;}
.cc-q-card .cc-q-sub {margin-bottom:16px;font-size:15px;line-height:1.5;color:#E9E7FD;}
.cc-q-card .cc-q-btn {position:relative;display:flex !important;align-items:center;justify-content:center;width:100%;height:56px;padding:0 16px;border:0;border-radius:999px;background:#fff;color:#5B52E0;font-size:16px;font-weight:700;line-height:1;}
.cc-q-card .cc-q-btn:hover,.cc-q-card .cc-q-btn:focus {background:#F1F0FE;color:#463DC9;}
.cc-q-btn-main {font-size:16px;font-weight:700;}
.cc-q-btn-sub {position:absolute;left:0;right:0;bottom:6px;text-align:center;font-size:10px;font-weight:600;color:#9aa0b0;letter-spacing:.2px;}
.cc-top-domain .cc-un-chip {margin:0;flex-shrink:0;}
.cc-q-wrap {margin-top:0;align-items:flex-start !important;}
.cc-q-label .cc-un-chip {margin-left:0;}
.cc-claim {border:1.5px dashed #c9c5f8 !important;background:transparent;padding:16px 18px;text-align:left;}
.cc-claim-top {font-size:12px;font-weight:700;color:#8a8fa3;letter-spacing:.3px;margin-bottom:4px;}
.cc-claim-title {font-size:17px;font-weight:700;color:#3d454e;}
.cc-claim-sub {font-size:14px;color:#6c7280;margin:2px 0 12px;}
.cc-claim-row {display:flex;align-items:center;gap:12px;flex-wrap:wrap;}
.cc-claim-row .btn {font-weight:700;}
.cc-claim-btn {height:48px;display:flex !important;align-items:center;justify-content:center;font-weight:700;}
.cc-claim-free {border-color:#766DF4 !important;background:#fff !important;}
.cc-empty {padding:28px 20px;text-align:center;}
.cc-empty-t {font-size:16px;font-weight:700;color:#3d454e;margin-bottom:4px;}
.cc-empty-s {font-size:14px;color:#6c7280;}
.cc-claim-paid {font-size:14px;font-weight:600;text-decoration:none;padding:10px 0;}



/* ===== 응원 / 싫어요 =====
   응원: 하루 1번, 점수는 비로그인 1 · 로그인 2 · 프리미엄 10 (싫어요 누르면 이 페이지의 내 응원 전부 취소)
   싫어요: 하루 1번, 취소 없음 (응원하면 오늘 싫어요 취소)
   두 숫자는 따로 보여주고 비율·점수로 합치지 않음 */
.cc-feel-card{padding:14px 16px 12px;text-align:left;}
.cc-feel-row{display:flex;align-items:center;gap:12px;}
.cc-feel-q{flex:1;min-width:0;}
.cc-feel-title{font-size:16px;font-weight:700;color:#3d454e;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
/* 오늘 응원을 다 쓴 뒤 한 번 더 누르면 버튼 아래에 뜨는 작은 말풍선 */
.cc-feel-card{position:relative;}
.cc-feel-tip{position:absolute;right:12px;z-index:6;display:none;max-width:calc(100% - 24px);padding:9px 14px;border-radius:12px;
  background:#3d454e;color:#fff;font-size:13px;font-weight:600;line-height:1.35;box-shadow:0 6px 18px rgba(0,0,0,.18);}


/* =========================================
   Cheer / Dislike Tooltip
========================================= */

.cc-feel-card {
        position: relative;
        overflow: visible;
}

.cc-feel-tip {
        position: absolute;
        display: none;
        top: 0;
        left: 12px;
        right: 12px;
        z-index: 100;

        width: auto;
        max-width: none;
        box-sizing: border-box;

        padding: 9px 14px;

        border-radius: 12px;
        background: #3d454e;
        color: #fff;

        font-size: 13px;
        font-weight: 600;
        line-height: 1.45;
        text-align: center;

        white-space: normal;
        overflow-wrap: break-word;

        box-shadow: 0 6px 18px rgba(0, 0, 0, .18);

        opacity: 0;
        visibility: hidden;
        pointer-events: auto;
}

.cc-feel-tip::before {
        content: "";
        position: absolute;

        top: -6px;
        left: var(--ax, 50%);

        margin-left: -6px;

        border: 6px solid transparent;
        border-top: 0;
        border-bottom-color: #3d454e;
}

.cc-feel-tip a {
        color: #c9c5f8;
        font-weight: 700;
        text-decoration: none;
}

.cc-feel-tip.show {
        display: block;
        opacity: 1;
        visibility: visible;

        animation: ccTipIn .18s ease;
}

@keyframes ccTipIn {
        from {
                opacity: 0;
                transform: translateY(-4px);
        }

        to {
                opacity: 1;
                transform: translateY(0);
        }
}

.cc-feel{display:flex;gap:6px;flex-shrink:0;}
.cc-feel-btn{position:relative;height:40px;padding:0 13px;border:1.5px solid #e1e0fe;border-radius:999px;background:#fff;color:#3d454e;
  display:inline-flex;align-items:center;gap:6px;font-size:14px;font-weight:700;cursor:pointer;
  transition:transform .12s ease,background .15s ease,border-color .15s ease,color .15s ease;-webkit-tap-highlight-color:transparent;}
.cc-feel-btn:hover{background:#f6f5ff;}
.cc-feel-btn:active{transform:scale(.94);}
.cc-feel-btn svg{width:17px;height:17px;flex-shrink:0;}
.cc-feel-btn[data-feel="1"] svg{color:#766DF4;}
.cc-feel-btn[data-feel="-1"] svg{color:#d63c41;}
.cc-feel-btn.on[data-feel="1"]{background:#766DF4;border-color:#766DF4;color:#fff;}
.cc-feel-btn.on[data-feel="-1"]{background:#d63c41;border-color:#d63c41;color:#fff;}
.cc-feel-btn.on svg{color:#fff;}
.cc-feel-btn.on[data-feel="1"] svg path{fill:currentColor;}
.cc-feel-btn.on[data-feel="-1"] svg path:last-child{fill:currentColor;}
.cc-feel-btn.done{cursor:default;}
.cc-feel-btn.done:active{transform:none;}
.cc-feel-btn.pop{animation:ccFeelPop .35s ease;}
@keyframes ccFeelPop{0%{transform:scale(1)}40%{transform:scale(1.12)}100%{transform:scale(1)}}
/* 응원 누르면 +1 이 떠오름 */
.cc-plus{position:absolute;left:50%;top:-6px;font-size:13px;font-weight:800;color:#766DF4;pointer-events:none;animation:ccPlus .7s ease forwards;}
@keyframes ccPlus{0%{opacity:0;transform:translate(-50%,4px)}20%{opacity:1}100%{opacity:0;transform:translate(-50%,-20px)}}
/* 오늘 남은 응원 (로그인·유료처럼 하루 2번 이상일 때만 표시) */
/* 메시지 카드: 글쓴이가 누른 쪽 표시 */
.cc-feel-chip{display:inline-flex;align-items:center;gap:3px;margin-left:6px;padding:1px 7px;border-radius:999px;font-size:11px;font-weight:700;vertical-align:1px;}
.cc-feel-chip svg{width:11px;height:11px;}
.cc-feel-chip.like{background:#f1f0fe;color:#766DF4;}
.cc-feel-chip.dislike{background:#fdecec;color:#d63c41;}
/* 응원 뒤 카드 안에 뜨는 작은 줄: "익명으로 응원했어요 · 이름 넣기" */
/* 카드 아래쪽: 응원한 사람 + 내 응원 상태 (작은 글씨) */
.cc-feel-foot{margin-top:10px;padding-top:8px;border-top:1px solid #f0effa;}
.cc-feel-foot:empty,.cc-feel-foot.none{display:none;}
.cc-cheer-by{display:flex;align-items:center;gap:6px;width:100%;padding:2px 0;border:0;background:none;text-align:left;font-size:12px;font-weight:600;color:#6c7280;cursor:pointer;}
.cc-cheer-by svg{width:13px;height:13px;color:#766DF4;flex-shrink:0;}
.cc-cheer-by b{color:#3d454e;font-weight:700;}
.cc-cheer-by .cc-chev{margin-left:auto;width:14px;height:14px;color:#b8bbc6;transition:transform .2s ease;}
.cc-cheer-by[aria-expanded="true"] .cc-chev{transform:rotate(180deg);}
.cc-cheer-as{font-size:12px;font-weight:600;color:#8a8fa3;margin-bottom:6px;}
.cc-cheer-as b{color:#766DF4;font-weight:700;}
.cc-cheer-as a{color:#766DF4;font-weight:700;text-decoration:none;}
.cc-cheer-as.pop{animation:ccFeelPop .35s ease;}
/* 이름 입력: 작은 알약 안에 ✓ 저장, ✕ 닫기 아이콘만 */
.cc-cheer-edit{display:flex;align-items:center;gap:2px;margin-bottom:8px;height:36px;padding:0 4px 0 12px;border:1.5px solid #e1e0fe;border-radius:999px;background:#fafaff;}
.cc-cheer-edit:focus-within{border-color:#766DF4;box-shadow:0 0 0 3px rgba(118,109,244,.15);background:#fff;}
.cc-cheer-edit input{flex:1;min-width:0;height:100%;border:0;background:transparent;font-size:16px;font-weight:600;color:#3d454e;outline:none;padding:0;}
.cc-cheer-ic{width:30px;height:30px;flex:0 0 30px;border:0;border-radius:50%;background:transparent;display:flex;align-items:center;justify-content:center;cursor:pointer;padding:0;}
.cc-cheer-ic svg{width:16px;height:16px;}
.cc-cheer-ic.ok{color:#766DF4;}
.cc-cheer-ic.ok:hover{background:#f1f0fe;}
.cc-cheer-ic.no{color:#b8bbc6;}
.cc-cheer-ic.no:hover{background:#f4f4f7;color:#8a8fa3;}
/* 응원한 사람 목록 (카드 안에서 펼침) */
.cc-cheer-list{margin-top:6px;max-height:228px;overflow-y:auto;-webkit-overflow-scrolling:touch;}
.cc-cheer-row{display:flex;align-items:center;gap:10px;padding:7px 0;}
.cc-cheer-row + .cc-cheer-row{border-top:1px solid #f6f5ff;}
.cc-cheer-av{width:28px;height:28px;flex:0 0 28px;border-radius:50%;background:#f1f0fe;color:#766DF4;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;}
.cc-cheer-row.anon .cc-cheer-av{background:#f4f4f7;color:#8a8fa3;}
.cc-cheer-nm{flex:1;min-width:0;font-size:14px;font-weight:600;color:#3d454e;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.cc-cheer-nm small{font-size:12px;font-weight:500;color:#8a8fa3;margin-left:4px;}
.cc-cheer-pt{font-size:12px;font-weight:700;color:#766DF4;white-space:nowrap;}
.cc-cheer-pt.m{background:#766DF4;color:#fff;border-radius:999px;padding:1px 7px;}
.cc-cheer-more{display:block;width:100%;padding:8px 0 2px;border:0;background:none;font-size:13px;font-weight:700;color:#766DF4;text-align:center;}
.cc-cheer-ask{display:flex;align-items:center;justify-content:center;gap:6px;width:100%;height:38px;margin:2px 0 10px;border:0;border-radius:999px;background:#f1f0fe;color:#766DF4;font-size:14px;font-weight:700;cursor:pointer;}
.cc-cheer-ask:hover{background:#e9e7fd;}
.cc-cheer-ask svg{width:16px;height:16px;}
.cc-cheer-rules-link{display:inline-flex;align-items:center;gap:5px;margin-top:6px;padding:6px 0 2px;font-size:12px;font-weight:700;color:#766DF4;text-decoration:none;}
.cc-cheer-rules-link svg{width:14px;height:14px;}
.cc-rules-modal{background-color:var(--bs-topnav-bg,#fff);border-radius:1rem;}
.cc-rules-modal .modal-body{padding:28px 24px 22px;text-align:left;}
.cc-rules-title{font-size:18px;font-weight:800;color:#3d454e;margin:0 28px 14px 0;}
.cc-rules-list{margin:0;padding-left:18px;font-size:14px;line-height:1.55;color:#545b66;}
.cc-rules-list li + li{margin-top:8px;}
.cc-rules-list b{color:#3d454e;font-weight:700;}


/* 응원 툴팁 로그인 링크 */
#ccFeelTip .cc-feel-signin {
        color: inherit;
        text-decoration: underline;
}

#ccFeelTip .cc-feel-signin:hover {
        color: inherit;
}

#ccCheerAs {
        color: inherit;
}

#ccCheerAs a {
        color: inherit;
        text-decoration: underline;
}

.cc-cheer-av {
        width: 28px;
        height: 28px;
        flex: 0 0 28px;
        border-radius: 50%;
        overflow: hidden;
        position: relative;

        background: #f1f0fe;
        color: #766DF4;

        display: flex;
        align-items: center;
        justify-content: center;

        font-size: 12px;
        font-weight: 700;
}

.cc-cheer-av img {
        width: 100%;
        height: 100%;
        border-radius: 50%;
        object-fit: cover;
        display: block;
}


/* 기본 placeholder */
#ccCheerName::placeholder,
#ccFind::placeholder {
        color: #ced0da;
        opacity: 1;
}

/* Chrome, Safari, Edge */
#ccCheerName::-webkit-input-placeholder,
#ccFind::-webkit-input-placeholder {
        color: #ced0da;
}

/* Firefox */
#ccCheerName::-moz-placeholder,
#ccFind::-moz-placeholder {
        color: #ced0da;
        opacity: 1;
}



/* 이름 변경 오류 툴팁 */
.cc-cheer-name-tooltip {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 10px;
        width: 100%;
        margin-top: 7px;
        padding: 9px 12px;
        background: #fff4f4;
        border: 1px solid #f1caca;
        border-radius: 6px;
        color: #c0392b;
        font-size: 12px;
        line-height: 1.5;
        box-sizing: border-box;
}

/* 닫기 버튼 */
.cc-cheer-name-tooltip-close {
        flex-shrink: 0;
        border: 0;
        padding: 0;
        margin: -3px -2px 0 0;
        background: transparent;
        color: #999;
        font-size: 19px;
        line-height: 1;
        cursor: pointer;
}

.cc-cheer-name-tooltip-close:hover {
        color: #333;
}





/* =========================================
   Cheer List Bottom Sheet Only
========================================= */

#ccCheerOverlay {
        position: fixed;
        inset: 0;
        z-index: 1090;
        display: block;
        background: rgba(0,0,0,.35);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity .25s ease, visibility .25s ease;
}

#ccCheerOverlay.show {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
}

#ccCheerSheet {
        position: fixed !important;
        left: 50% !important;
        right: auto !important;
        top: auto !important;
        bottom: 0 !important;
        width: 100%;
        max-width: 400px;

        /* 원본 Sheet 높이 */
        height: auto;
        min-height: 0;
        max-height: min(55vh, 480px);

        margin: 0 !important;
        z-index: 1091;
        display: flex;
        flex-direction: column;
        background: #fff;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -5px 28px rgba(0,0,0,.16);
        transform: translate(-50%,105%);
        visibility: hidden;
        overflow: hidden;
        transition: transform .3s cubic-bezier(.22,1,.36,1), visibility .3s ease;
}

#ccCheerSheet.show {
        transform: translate(-50%,0);
        visibility: visible;
}

/* 상단 타이틀 */
/* 상단 타이틀 - 원본 스타일 */

#ccCheerSheet .popup-header-line {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        flex: 0 0 auto;
        height: auto;
        min-height: 0;
        padding: 0;
        border-bottom: 0;
        background: transparent;
}

/* 제목 부분 - 원본과 동일 */

#ccCheerSheet .popup-header-line {
        display: flex;
        justify-content: center;
        align-items: center;
        position: relative;
        flex: 0 0 auto;
        height: auto;
        min-height: 0;
        padding: 0.5rem 1rem 0.25rem;
        background-color: #f8f9fa;
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
        border-bottom: 0;
}

#ccCheerSheet .popup-address {
        font-size: 1.1rem;
        font-weight: 600;
        color: #4a4a4a;
        text-align: center;
}

#ccCheerSheet .cc-cheer-sheet-n {
        font-size: 14px;
        font-weight: 700;
        color: #766DF4;
        margin-left: 4px;
}

#ccCheerSheet .popup-close {
        position: absolute !important;
        right: 12px !important;
        top: 6px !important;
        transform: scale(0.8) !important;
}

/* 목록 스크롤 영역 */

#ccCheerSheet .cc-cheer-sheet-body {
        display: block !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        width: 100%;
        padding: 4px 18px 0;
        overflow-x: hidden;
        overflow-y: auto !important;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        text-align: left;
}

/* 목록 */

#ccCheerSheet #ccCheerList {
        display: flow-root !important;
        position: relative !important;
        width: 100% !important;
        height: auto !important;
        min-height: 1px !important;
        max-height: none !important;
        margin: 0;
        padding: 0;
        overflow: visible !important;
}

/* 응원자 한 명 */

#ccCheerSheet #ccCheerList .cc-cheer-row {
        display: flex !important;
        align-items: center;
        position: relative !important;
        float: none !important;
        width: 100% !important;
        height: auto !important;
        min-height: 56px !important;
        flex: 0 0 auto !important;
        gap: 11px;
        padding: 10px 2px;
        border-bottom: 1px solid #f3f3f5;
}

#ccCheerSheet #ccCheerList .cc-cheer-av {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        flex: 0 0 36px;
        border-radius: 50%;
        background: #f1f0fe;
        color: #766DF4;
        font-size: 14px;
        font-weight: 700;
}

#ccCheerSheet #ccCheerList .cc-cheer-row.anon .cc-cheer-av {
        background: #f4f4f7;
        color: #8a8fa3;
}

#ccCheerSheet #ccCheerList .cc-cheer-nm {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 14px;
        font-weight: 600;
        color: #3d454e;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
}

#ccCheerSheet #ccCheerList .cc-cheer-nm small {
        margin-left: 6px;
        font-size: 11px;
        font-weight: 400;
        color: #a0a3ad;
}

#ccCheerSheet #ccCheerList .cc-cheer-pt {
        flex: 0 0 auto;
        font-size: 13px;
        font-weight: 700;
        color: #766DF4;
        white-space: nowrap;
}

#ccCheerSheet #ccCheerList .cc-cheer-pt.m {
        padding: 3px 9px;
        border-radius: 999px;
        background: #f1f0fe;
        color: #766DF4;
}

/* 더보기 */

#ccCheerSheet #ccCheerList .cc-cheer-more {
        display: block;
        width: 100%;
        height: 42px;
        margin: 12px 0;
        border: 0;
        border-radius: 999px;
        background: #f5f4ff;
        color: #766DF4;
        font-size: 13px;
        font-weight: 700;
        cursor: pointer;
}

#ccCheerSheet #ccCheerList .cc-cheer-more:disabled {
        opacity: .55;
        cursor: default;
}

#ccCheerSheet #ccCheerList .cc-cheer-end {
        padding: 14px 0;
        color: #a3a7b6;
        font-size: 12px;
        text-align: center;
}


/* 하단 How cheers work - 원본과 동일 */

#ccCheerSheet .cc-cheer-sheet-foot {
        display: block;
        flex: 0 0 auto;
        min-height: 0;
        padding: 6px 18px calc(12px + env(safe-area-inset-bottom));
        border-top: 1px solid #f0effa;
        background: transparent;
        text-align: left;
}

#ccCheerSheet .cc-cheer-rules-link {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        margin-top: 6px;
        padding: 6px 0 2px;
        font-size: 12px;
        font-weight: 700;
        color: #766DF4;
        text-decoration: none;
}

#ccCheerSheet .cc-cheer-rules-link svg {
        width: 14px;
        height: 14px;
}


/* 배경 스크롤 방지 */

body.cc-cheer-sheet-open {
        overflow: hidden;
}

/* 모션 최소화 설정 */

@media (prefers-reduced-motion: reduce) {
        #ccCheerSheet,
        #ccCheerOverlay {
                transition: none;
        }
}






/* =========================================
   Cheer Rules Modal - Cheer Sheet 위에 표시
========================================= */

/* 모달 배경 */
#ccCheerRulesModal {
        z-index: 1105 !important;
}

/* 모달 배경 오버레이 */
.modal-backdrop {
        z-index: 1100 !important;
}

/* 모달 본체 */
#ccCheerRulesModal .modal-dialog {
        position: relative;
        z-index: 1106;
}

/* Cheer Sheet는 모달보다 아래 */
#ccCheerSheet {
        z-index: 1091 !important;
}

#ccCheerOverlay {
        z-index: 1090 !important;
}















/* ===== 내 활동 서랍 ===== */

#ccActivity {
        width:340px;
        max-width:88vw;
        background:#fff;
        border-right:0;
}

#ccActivity .offcanvas-header {
        padding:calc(14px + env(safe-area-inset-top)) 16px 6px 20px;
}

.cc-act-title {
        font-size:20px;
        font-weight:800;
        letter-spacing:-.3px;
        color:#3d454e;
        margin:0;
}

.cc-act-who {
        display:flex;
        align-items:center;
        gap:10px;
        margin:4px 20px 12px;
        padding:10px 12px;
        border-radius:14px;
        background:#f6f5ff;
        font-size:13px;
        color:#6c7280;
}

.cc-act-who svg {
        width:18px;
        height:18px;
        color:#766DF4;
        flex-shrink:0;
}

.cc-act-who b {
        color:#3d454e;
}

.cc-act-who a {
        font-weight:700;
        color:#766DF4;
        text-decoration:none;
}

/* 로그인 사용자 정보 */

.cc-act-who.in {
        padding:8px 14px 8px 8px;
        gap:10px;
}

.cc-acct-ph {
        position:relative;
        width:36px;
        height:36px;
        flex:0 0 36px;
        border-radius:50%;
        overflow:hidden;
        background:#e9e7fd;
        color:#5B52E0;
        display:flex;
        align-items:center;
        justify-content:center;
        font-size:15px;
        font-weight:800;
}

.cc-acct-ph img {
        position:absolute;
        inset:0;
        width:100%;
        height:100%;
        object-fit:cover;
        padding:0 !important;
        border:0 !important;
}

.cc-acct-who {
        flex:1;
        min-width:0;
        display:flex;
        flex-direction:column;
        line-height:1.3;
}

.cc-acct-who b {
        font-size:13px;
        font-weight:700;
        color:#3d454e;
        white-space:nowrap;
        overflow:hidden;
        text-overflow:ellipsis;
}

.cc-acct-who span {
        font-size:12px;
        color:#a3a7b6;
        white-space:nowrap;
        overflow:hidden;
        text-overflow:ellipsis;
}

/* ===== 관심 페이지 목록 ===== */

.cc-pg-count {
        font-size:15px;
        font-weight:600;
        color:#a3a7b6;
        margin-left:2px;
}

.cc-pg-desc {
        font-size:13px;
        color:#8a8fa3;
        margin-top:2px;
}

.cc-pg {
        position:relative;
        display:flex;
        align-items:center;
        gap:8px;
        padding:12px 10px;
        margin:0 -10px;
        border-radius:14px;
        text-decoration:none;
        color:inherit;
}

.cc-pg:hover {
        background:#f8f7ff;
}

.cc-pg + .cc-pg {
        margin-top:2px;
}

.cc-pg-body {
        flex:1;
        min-width:0;
}

.cc-pg-row {
        display:flex;
        align-items:center;
        gap:8px;
}

.cc-pg-row.sub {
        margin-top:4px;
        gap:12px;
}

.cc-pg-url {
        flex:1;
        min-width:0;
        font-size:16px;
        font-weight:800;
        letter-spacing:-.2px;
        color:#3d454e;
        white-space:nowrap;
        overflow:hidden;
        text-overflow:ellipsis;
}

.cc-pg-url .cc-td-tld {
        color:#a3a7b6;
        font-weight:700;
}

.cc-pg-time {
        font-size:12px;
        color:#a3a7b6;
        white-space:nowrap;
}

.cc-pg-row .cc-pg-time {
        flex-shrink:0;
}

/* 정렬 토글 */

.cc-pg-sort {
        display:flex;
        gap:4px;
        margin:0 20px 6px;
        padding:3px;
        border-radius:999px;
        background:#f4f3fe;
}

.cc-pg-sort button {
        flex:1;
        height:32px;
        border:0;
        border-radius:999px;
        background:transparent;
        color:#6c7280;
        font-size:13px;
        font-weight:700;
        cursor:pointer;
}

.cc-pg-sort button.on {
        background:#fff;
        color:#766DF4;
        box-shadow:0 1px 4px rgba(91,82,224,.15);
}

/* 줄 삭제 */

.cc-pg-x {
        width:32px;
        height:32px;
        flex:0 0 32px;
        border:0;
        border-radius:50%;
        background:transparent;
        color:#c3c6d1;
        display:flex;
        align-items:center;
        justify-content:center;
        padding:0;
        cursor:pointer;
}

.cc-pg-x:hover {
        background:#f4f4f7;
        color:#6c7280;
}

.cc-pg-x svg {
        width:15px;
        height:15px;
}

/* 삭제 취소 */

.cc-pg-undo {
        display:flex;
        align-items:center;
        justify-content:space-between;
        padding:12px 10px;
        margin:0 -10px;
        border-radius:14px;
        background:#f8f9fa;
        font-size:13px;
        color:#6c7280;
}

.cc-pg-undo a {
        font-weight:700;
        color:#766DF4;
        text-decoration:none;
}

/* 페이지 통계 */

.cc-pg-stat {
        display:inline-flex;
        align-items:center;
        gap:4px;
        font-size:12px;
        font-weight:600;
        color:#8a8fa3;
        white-space:nowrap;
}

.cc-pg-stat svg {
        width:13px;
        height:13px;
        flex-shrink:0;
}

.cc-pg-stat.cheer svg {
        color:#766DF4;
}

.cc-pg-stat.post svg {
        color:#a3a7b6;
}

/* 새 글 / 답변 뱃지 */

.cc-pg-badges {
        display:flex;
        gap:4px;
        margin-left:auto;
        flex-shrink:0;
}

.cc-pg-badge {
        display:inline-flex;
        align-items:center;
        gap:3px;
        height:20px;
        padding:0 8px;
        border-radius:999px;
        font-size:11px;
        font-weight:800;
        white-space:nowrap;
        line-height:1;
}

.cc-pg-badge svg {
        width:11px;
        height:11px;
}

.cc-pg-badge.reply,
.cc-pg-badge.post {
        background:#d63c41;
        color:#fff;
}

.cc-pg.unread {
        background:#faf9ff;
}

.cc-pg-sep {
        font-size:11px;
        font-weight:800;
        color:#a3a7b6;
        letter-spacing:.4px;
        text-transform:uppercase;
        padding:12px 0 4px;
}

.cc-pg-sep:first-child {
        padding-top:6px;
}

.cc-pg-time.here {
        color:#766DF4;
        font-weight:700;
}

.cc-pg.is-here {
        background:#f6f5ff;
}

.cc-pg.visited .cc-pg-url {
        font-weight:700;
        color:#545b66;
}

/* ===== 서랍 하단 고정 검색 영역 ===== */

.cc-act-foot {
        border-top:1px solid #f0effa;
        padding:14px 18px calc(12px + env(safe-area-inset-bottom));
        background:#fbfaff;
}

.cc-find-title {
        font-size:16px;
        font-weight:800;
        color:#3d454e;
        letter-spacing:-.2px;
}

.cc-find-sub {
        font-size:13px;
        color:#8a8fa3;
        margin:1px 0 10px;
}

.cc-find-form {
        display:flex;
        gap:8px;
}

.cc-find-input {
        flex:1;
        min-width:0;
        display:flex;
        align-items:center;
        gap:6px;
        height:46px;
        padding:0 14px 0 12px;
        border:1.5px solid #e1e0fe;
        border-radius:999px;
        background:#fff;
}

.cc-find-input:focus-within {
        border-color:#766DF4;
        box-shadow:0 0 0 3px rgba(118,109,244,.18);
}

.cc-find-input svg {
        width:17px;
        height:17px;
        flex-shrink:0;
        color:#a3a7b6;
}

.cc-find-input input {
        flex:1;
        min-width:0;
        border:0;
        background:transparent;
        outline:none;
        font-size:16px !important;
        font-weight:600;
        color:#3d454e;
        padding:0;
}

.cc-find-tld {
        font-size:16px;
        font-weight:600;
        color:#766DF4;
        flex-shrink:0;
}

.cc-find-go {
        width:46px;
        height:46px;
        flex:0 0 46px;
        border:0;
        border-radius:50%;
        background:#766DF4;
        color:#fff;
        font-size:20px;
        font-weight:800;
        display:flex;
        align-items:center;
        justify-content:center;
        cursor:pointer;
}

.cc-find-go:disabled {
        background:#d6d3fb;
        cursor:default;
}

.cc-find-hot {
        display:inline-flex;
        align-items:center;
        gap:5px;
        margin-top:10px;
        padding:4px 2px;
        font-size:13px;
        font-weight:700;
        color:#766DF4;
        text-decoration:none;
}

.cc-find-hot svg {
        width:14px;
        height:14px;
        color:#f08a24;
}

/* 목록 영역 */

#ccActivity .offcanvas-body {
        padding:4px 20px 20px;
}
















/* =========================================
   내 활동 서랍 - 추가 스타일
========================================= */

/* 활동 탭 */

.cc-act-tabs {
        display:flex;
        gap:6px;
        padding:0 20px 10px;
        border-bottom:1px solid #f0effa;
}

.cc-act-tab {
        height:34px;
        padding:0 12px;
        border:1.5px solid #e1e0fe;
        border-radius:999px;
        background:#fff;
        color:#6c7280;
        font-size:13px;
        font-weight:700;
        display:inline-flex;
        align-items:center;
        gap:5px;
        cursor:pointer;
}

.cc-act-tab .n {
        font-weight:600;
        color:#a3a7b6;
}

.cc-act-tab.on {
        background:#766DF4;
        border-color:#766DF4;
        color:#fff;
}

.cc-act-tab.on .n {
        color:#E9E7FD;
}


/* =========================================
   활동 목록
========================================= */

.cc-act-item {
        display:flex;
        gap:12px;
        padding:13px 0;
        text-decoration:none;
        color:inherit;
}

.cc-act-item + .cc-act-item {
        border-top:1px solid #f6f5ff;
}

.cc-act-ic {
        width:34px;
        height:34px;
        flex:0 0 34px;
        border-radius:50%;
        display:flex;
        align-items:center;
        justify-content:center;
}

.cc-act-ic svg {
        width:16px;
        height:16px;
}

.cc-act-ic.post,
.cc-act-ic.cheer {
        background:#f1f0fe;
        color:#766DF4;
}

.cc-act-ic.reply {
        background:#eef7f2;
        color:#1a8f55;
}

.cc-act-ic.dislike {
        background:#fdecec;
        color:#d63c41;
}

.cc-act-body {
        flex:1;
        min-width:0;
}

.cc-act-top {
        display:flex;
        align-items:center;
        gap:6px;
        font-size:12px;
        color:#8a8fa3;
}

.cc-act-page {
        font-weight:700;
        color:#766DF4;
        white-space:nowrap;
        overflow:hidden;
        text-overflow:ellipsis;
}

.cc-act-time {
        margin-left:auto;
        white-space:nowrap;
}

.cc-act-text {
        font-size:14px;
        line-height:1.45;
        color:#3d454e;
        margin-top:2px;
        display:-webkit-box;
        -webkit-line-clamp:2;
        -webkit-box-orient:vertical;
        overflow:hidden;
        word-break:break-word;
}

.cc-act-sub {
        display:flex;
        align-items:center;
        gap:10px;
        margin-top:5px;
        font-size:12px;
        font-weight:600;
        color:#8a8fa3;
}

.cc-act-new {
        background:#d63c41;
        color:#fff;
        border-radius:999px;
        padding:1px 7px;
        font-size:11px;
        font-weight:700;
}

.cc-act-empty {
        text-align:center;
        padding:40px 10px;
        color:#8a8fa3;
        font-size:14px;
}

.cc-act-empty b {
        display:block;
        color:#3d454e;
        font-size:16px;
        margin-bottom:4px;
}


/* =========================================
   인기 페이지 버튼
========================================= */

.cc-hot-btn {
        display:flex;
        align-items:center;
        gap:8px;
        height:44px;
        padding:0 14px;
        border-radius:14px;
        background:#f6f5ff;
        color:#766DF4 !important;
        font-size:15px;
        font-weight:800;
        text-decoration:none;
}

.cc-hot-btn:hover {
        background:#eeecff;
        color:#463DC9 !important;
}

.cc-hot-btn svg {
        width:18px;
        height:18px;
        color:#f08a24;
}

.cc-hot-arrow {
        margin-left:auto;
        transition:transform .2s ease;
}

.cc-hot-btn:hover .cc-hot-arrow {
        transform:translateX(3px);
}


/* =========================================
   페이지 안 메시지 카드 - 새 글 / 내 글
========================================= */

.cc-new-chip {
        display:inline-block;
        margin-left:6px;
        padding:1px 7px;
        border-radius:999px;
        background:#d63c41;
        color:#fff;
        font-size:11px;
        font-weight:700;
        vertical-align:1px;
}

.cc-mine-chip {
        display:inline-block;
        margin-left:6px;
        padding:1px 7px;
        border-radius:999px;
        background:#f1f0fe;
        color:#766DF4;
        font-size:11px;
        font-weight:700;
        vertical-align:1px;
}

.cc-msg-card.is-new {
        border-color:#c9c5f8 !important;
        box-shadow:0 0 0 2px rgba(118,109,244,.12);
}

.cc-stat-new {
        margin-left:2px;
        padding:1px 7px;
        border-radius:999px;
        background:#d63c41;
        color:#fff;
        font-size:11px;
        font-weight:700;
}

.cc-rep.is-new .cc-rep-name::after {
        content:"New";
        margin-left:6px;
        padding:1px 6px;
        border-radius:999px;
        background:#d63c41;
        color:#fff;
        font-size:10px;
        font-weight:700;
        vertical-align:1px;
}


</style>


<header class="cc-top-domain">
        <!-- 좌상단: 내가 관심 가진 페이지 서랍 열기 -->
        <button type="button" class="cc-hd-btn cc-hd-left" id="ccActOpen" data-bs-toggle="offcanvas" data-bs-target="#ccActivity" aria-controls="ccActivity" aria-label="Pages you're in">
                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 6h16M4 12h16M4 18h10"></path></svg>
        </button>

        <div class="cc-td-name">
                        <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
                                <circle cx="12" cy="12" r="10"/>
                                <path d="M2 12h20"/>
                                <path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/>
                        </svg>
                <span class="cc-slug">myperfumecenter</span><span class="cc-td-tld">.co.cc</span>
        </div>

        <!-- 우상단: 클라우드 → 메인 (기존에 만든 클라우드 아이콘 SVG로 교체) -->
        <a href="https://co.cc" class="cc-hd-btn cc-hd-right" aria-label="Explore names">
                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17.5 19H8a5 5 0 1 1 1.1-9.88A6 6 0 0 1 20.5 12 3.5 3.5 0 0 1 17.5 19Z"></path></svg>
        </a>
</header>
<div class="d-flex justify-content-center mb-2 cc-q-wrap">
        <div class="card card-fixed-width cc-q-card">
                <h1 class="cc-q-title">Say anything to <span class="cc-name">myperfumecenter</span></h1>
                <div class="cc-q-hint"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"></path></svg>No sign-up needed</div>
                <button type="button" class="btn rounded-pill w-100 cc-q-btn" id="ccQWrite">
                        <span class="cc-q-btn-main" id="ccQWriteMain">Say it anonymously</span>
                </button>
        </div>
</div>



<!-- 응원 / 싫어요: 별도 카드 (보라 박스 아래) -->
<div class="d-flex justify-content-center mb-2">
        <div class="card bg-white card-fixed-width cc-feel-card">
                <div class="cc-feel-row">
                        <div class="cc-feel-q">
                                <div class="cc-feel-title">Cheer for <span class="cc-name">myperfumecenter</span>?</div>
                        </div>
                        <div class="cc-feel" id="ccFeel" role="group" aria-label="Cheer or dislike">
                                <button type="button" class="cc-feel-btn" data-feel="1" aria-pressed="false" aria-label="Cheer"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"></path></svg><span class="cc-feel-n" id="ccFeelCheerN">0</span></button>
                                <button type="button" class="cc-feel-btn" data-feel="-1" aria-pressed="false" aria-label="Dislike"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 14V2"></path><path d="M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H17v12l-5 8a3.13 3.13 0 0 1-3-3.88Z"></path></svg><span class="cc-feel-n" id="ccFeelDislikeN">0</span></button>
                        </div>
                </div>
                <div class="cc-feel-tip" id="ccFeelTip" role="status" aria-live="polite"></div>
                <div class="cc-feel-foot" id="ccFeelFoot">
                        <!-- 1) 내가 응원한 뒤에만 보임: 누구로 응원했는지 + 이름 넣기 -->
                        <div class="cc-cheer-as" id="ccCheerAs" style="display:none"></div>
                        <form class="cc-cheer-edit" id="ccCheerEdit" style="display:none" autocomplete="off">
                                <label for="ccCheerName" class="visually-hidden">Your name</label>
                                <input type="text" id="ccCheerName" maxlength="20" placeholder="Your name" autocorrect="off" autocapitalize="off" spellcheck="false" enterkeyhint="done">
                                <button type="submit" class="cc-cheer-ic ok" aria-label="Save name"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"></path></svg></button>
                                <button type="button" class="cc-cheer-ic no" id="ccCheerEditClose" aria-label="Close"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18M6 6l12 12"></path></svg></button>
                        </form>
                        <!-- 1-1) 응원한 뒤: 친구에게 응원 부탁 (공유) -->
                        <button type="button" class="cc-cheer-ask" id="ccCheerAsk" style="display:none"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 12v7a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7"></path><path d="M16 6l-4-4-4 4"></path><path d="M12 2v13"></path></svg>Ask friends to cheer 💜</button>
                        <!-- 2) 응원한 사람: "Mina, Daniel and 2.1k others" → 누르면 시간순 목록 펼침 -->
                        <button type="button" class="cc-cheer-by" id="ccCheerBy" aria-expanded="false" aria-controls="ccCheerPanel" style="display:none"></button>
                </div>
        </div>
</div>




<!-- 응원한 사람 목록: 하단에서 올라오는 시트 -->
<div class="popup-overlay" id="ccCheerOverlay"></div>
<div class="offcanvas-static max-400" id="ccCheerSheet" role="dialog" aria-labelledby="ccCheerSheetTitle">
        <div class="popup-header-line">
                <div class="popup-address" id="ccCheerSheetTitle">Cheers <span class="cc-cheer-sheet-n" id="ccCheerSheetN"></span></div>
                <button type="button" class="btn-close popup-close" id="ccCheerSheetClose" aria-label="Close" style="position:absolute;right:12px;top:10px;"></button>
        </div>
        <div class="cc-cheer-sheet-body">
                <div class="cc-cheer-list" id="ccCheerList"></div>
        </div>
        <div class="cc-cheer-sheet-foot">
                <!-- 규칙 설명은 링크 → 팝업 -->
                <a href="javascript:void(0)" class="cc-cheer-rules-link" data-bs-toggle="modal" data-bs-target="#ccCheerRulesModal"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"></circle><path d="M12 16v-4M12 8h.01"></path></svg>How cheers count</a>
        </div>
</div>




<!-- ===== 내가 관심 가진 페이지 서랍 (추가) ===== -->
<div class="offcanvas offcanvas-start" tabindex="-1" id="ccActivity" aria-labelledby="ccActTitle">
        <div class="offcanvas-header">
                <div>
                        <h5 class="cc-act-title" id="ccActTitle">Pages you're in <span class="cc-pg-count" id="ccPgCount"></span></h5>
                </div>
                <button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
        </div>
        <div class="cc-act-who" id="ccActWho">
                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="5" y="11" width="14" height="10" rx="2"></rect><path d="M8 11V7a4 4 0 0 1 8 0v4"></path></svg>
                <span>Saved on this device only. <a href="https://co.cc/login/login.php" class="cc-act-signin">Sign in</a> to keep it.</span>
        </div>

        <div class="cc-pg-sort" role="tablist" id="ccPgSort">
                <button type="button" class="on" data-sort="cheers" role="tab" aria-selected="true">Most cheers</button>
                <button type="button" data-sort="recent" role="tab" aria-selected="false">Recent</button>
        </div>
        <div class="offcanvas-body" id="ccActList"></div>
        <!-- 서랍 하단 고정: 목록이 길어져도 항상 보임 -->
        <div class="cc-act-foot">
                <div class="cc-find-title">Curious about someone?</div>
                <div class="cc-find-sub">Search a name. Leave an anonymous note or cheer.</div>
                <form class="cc-find-form" id="ccFindForm" autocomplete="off" role="search">
                        <label for="ccFind" class="visually-hidden">Name</label>
                        <div class="cc-find-input">
                                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="11" cy="11" r="7"></circle><path d="m20 20-3.5-3.5"></path></svg>
                                <input id="ccFind" type="text" maxlength="40" placeholder="name" autocapitalize="off" autocorrect="off" spellcheck="false" enterkeyhint="go">
                                <span class="cc-find-tld">.co.cc</span>
                        </div>
                        <button type="submit" class="cc-find-go" disabled aria-label="Go">→</button>
                </form>
                <a href="https://co.cc" class="cc-find-hot">
                        <svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 2c.6 3.1-.8 5.2-2.4 7.1C8.2 10.8 7 12.4 7 14.6 7 17.6 9.2 20 12 20s5-2.4 5-5.4c0-1.4-.5-2.6-1.2-3.6-.3 1.3-1 2.2-2 2.6.4-2.9-.4-6.8-1.8-11.6Z"></path></svg>
                        or explore hot names
                </a>
        </div>
</div>

<!-- 응원 규칙 팝업 (모달은 body 바로 아래에 둬야 배경에 가려지지 않음) -->
<div class="modal fade" id="ccCheerRulesModal" tabindex="-1" aria-labelledby="ccCheerRulesTitle" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered">
                <div class="modal-content cc-rules-modal">
                        <div class="modal-body">
                                <div class="position-absolute end-0 top-0 p-3">
                                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                                </div>
                                <h5 class="cc-rules-title" id="ccCheerRulesTitle">💜 How cheers count</h5>
                                <ul class="cc-rules-list">
                                        <li>You can cheer and dislike each page <b>once a day</b>.</li>
                                        <li><b>Not signed in: 1 point.</b> Counted by network (IP address). If people share one network, only the last cheer counts.</li>
                                        <li><b>Signed in: 2 points.</b> If signed-in people cheer from the same network, only the last cheer counts.</li>
                                        <li><b>Premium members: 10 points.</b></li>
                                        <li>Cheers from VPNs and proxies are never counted, even if you're signed in or a premium member.</li>
                                        <li>A dislike cancels <b>all your cheers</b> on this page. A cheer cancels your dislike for today.</li>
                                        <li>Cheers are anonymous unless you add your name.</li>
                                </ul>
                        </div>
                </div>
        </div>
</div>


<!-- 댓글 목록 헤더 & 정렬 (reply_inc.php 연동) -->
<div class="d-flex justify-content-center">
        <div class="card-fixed-width border-0 bg-transparent">
                <div class="cc-msg-head d-none" id="ccMsgHeadWrap">
                        <div class="cc-msg-title">Messages <span id="ccMsgCount" class="text-muted fw-normal fs-6">(0)</span></div>
                        <div class="small cc-sort-wrap">
                                <a href="#" id="ccMsgTop" class="cc-sort-link active">Top</a>
                                <span class="text-secondary mx-1">·</span>
                                <a href="#" id="ccMsgNewest" class="cc-sort-link">Newest</a>
                        </div>
                </div>
        </div>
</div>

<div id="ccMsgListWrap" style="position:relative;">

        <div id="ccMsgSortLoading" style="display:none;">
                <div class="cc-msg-auto-loading">
                        <span></span>
                        <span></span>
                        <span></span>
                        <span></span>
                        <span></span>
                </div>
                <div class="text-center text-muted small">
                        Loading ...
                </div>
        </div>

        <div id="ccMsgList"></div>

</div>

<!-- 댓글 카드 리스트 (reply_inc.php에서 렌더링) -->
<div id="ccMsgList"></div>

<!-- 자동 스크롤 로딩 애니메이션 (reply_inc.php 연동) -->
<div id="ccMsgAutoLoading" class="cc-msg-auto-loading" style="display:none;">
        <span></span>
        <span></span>
        <span></span>
        <span></span>
        <span></span>
</div>

<!-- 더보기 버튼 영역 (reply_inc.php 연동) -->
<div class="text-center d-none" id="ccMsgMoreWrap">
        <a href="#" class="cc-msg-more text-primary">See more messages</a>
</div>
<script>
function getCookie(name) {
        const match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
        if (match) return match[2];
        return null;
}
</script>
<style>

/* 상세창이 열렸을 때 배경 페이지 스크롤 방지 */
body.cc-msg-open { overflow: hidden; }

/* 상세창 내부 스크롤이 바깥 페이지로 전달되지 않도록 방지 */
#ccViewScroll { overflow-y: auto; overscroll-behavior-y: contain; }

/* 메시지 목록 */
.cc-msg-head { display:flex; justify-content:space-between; align-items:baseline; padding:18px 6px 10px; border:0 !important; }
.cc-msg-title { font-size:18px; font-weight:700; color:#3d454e; }
.cc-msg-card { padding:16px 18px; text-align:left; cursor:pointer; }
.cc-msg-meta { display:flex; justify-content:space-between; font-size:12px; color:#8a8fa3; margin-bottom:6px; }
.cc-msg-meta span:first-child { font-weight:600; }
.cc-msg-text { font-size:16px; font-weight:500; line-height:1.45; word-break:break-word; }
.cc-msg-clamp { display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; white-space:pre-line; }
.cc-msg-foot { display:flex; align-items:center; gap:10px; margin-top:10px; }
.cc-stat { display:inline-flex; align-items:center; gap:6px; min-height:36px; color:#6c7280; font-size:13px; font-weight:600; }
.cc-msg-more { display:inline-block; padding:12px 16px; font-size:15px; font-weight:600; text-decoration:none; }
.cc-msg-more:hover { text-decoration:underline; }

/* 메시지 답글 미리보기 */
.cc-msg-reply { display:flex; gap:10px; margin-top:12px; padding:10px 12px; background:#f6f5ff; border-radius:12px; }
.cc-msg-reply-av { width:28px !important; height:28px !important; max-width:28px !important; min-width:28px; object-fit:cover; flex:0 0 28px; padding:0 !important; border:0 !important; }
.cc-msg-reply>div { flex:1; min-width:0; }
.cc-msg-reply-who { font-size:12px; font-weight:700; }
.cc-msg-reply-txt { font-size:14px; line-height:1.45; }


/* 하단 고정 한 줄 */
.cc-msg-bar{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(10px + env(safe-area-inset-bottom));
  width:380px;max-width:calc(100% - 20px);display:flex;align-items:center;gap:8px;padding:6px 6px 6px 18px;
  background:#fff;border:1px solid #e1e0fe;border-radius:999px;box-shadow:0 4px 16px rgba(118,109,244,.18);z-index:14;cursor:text;}
.cc-msg-bar{cursor:default;padding-left:6px !important;}
.cc-bar-pages{flex:1;min-width:0;height:44px;display:flex;align-items:center;gap:8px;padding:0 12px;border:0;border-radius:999px;background:transparent;
  color:#3d454e;font-size:16px;font-weight:700;text-align:left;cursor:pointer;-webkit-tap-highlight-color:transparent;}
.cc-bar-pages:hover{background:#f6f5ff;}
.cc-bar-pages:active{background:#eeecff;}
.cc-bar-pages:focus:not(:focus-visible){outline:none;}
.cc-bar-pages:focus-visible{outline:2px solid #766DF4;outline-offset:-2px;}
.cc-bar-pages svg{width:20px;height:20px;flex-shrink:0;color:#766DF4;}
.cc-bar-label{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
/* 새 소식: 내 글 답변 달린 페이지 수(빨간 숫자) / 새 글만이면 빨간 점 */
.cc-bar-badge{display:none;flex-shrink:0;min-width:20px;height:20px;padding:0 6px;border-radius:999px;background:#d63c41;color:#fff;font-size:12px;font-weight:800;line-height:20px;text-align:center;}
.cc-bar-badge.dot{min-width:9px;width:9px;height:9px;padding:0;}
.cc-bar-pages.has-new .cc-bar-badge{display:inline-block;}
/* 업데이트 있을 때: 아이콘만 살짝 깜빡임 (3번) / 내 글에 답변이면 아이콘이 빨간색. 테두리·글자는 그대로 */
.cc-bar-ic{display:inline-flex;flex-shrink:0;}
.cc-msg-bar.has-new .cc-bar-ic{animation:ccIcBlink 1.2s ease-in-out .6s 3;}
.cc-msg-bar.has-reply .cc-bar-pages svg{color:#d63c41;}
@keyframes ccIcBlink{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.35;transform:scale(.9)}}
@media (prefers-reduced-motion:reduce){.cc-msg-bar.has-new .cc-bar-ic{animation:none}}
.cc-msg-bar-btn{width:44px;height:44px;flex-shrink:0;border:0;border-radius:50%;display:flex;align-items:center;justify-content:center;}


/* 하단 Get your co.cc 배지 숨김 */
.powered-by { display:none !important; }
.container { margin-bottom:90px !important; }
body.cc-msg-open .powered-by, body.cc-msg-open .cc-msg-bar { display:none !important; }

/* 메시지 입력 팝업 */
#ccMsgPopup .popup-body { text-align:left; padding:0.75rem 1rem calc(1rem + env(safe-area-inset-bottom)); }
#ccMsgPopup textarea, #ccMsgPopup input { font-size:16px; }
#ccMsgPopup .cc-msg-anon { display:flex; align-items:center; gap:8px; min-height:44px; padding-left:0; }
#ccMsgPopup .cc-msg-anon .form-check-input { width:20px; height:20px; margin:0; float:none; flex-shrink:0; cursor:pointer; }
#ccMsgPopup .cc-msg-anon .form-check-label { font-size:15px; font-weight:600; color:#3d454e; cursor:pointer; }
#ccMsgPopup .cc-msg-who { font-size:12px; color:#8a8fa3; margin-top:-6px; }
#ccMsgPopup .cc-msg-note { font-size:12px; color:#8a8fa3; text-align:center; margin-top:8px; }

/* 점수가 가장 높은 답변 미리보기 */
.cc-top-rep { display:flex; gap:8px; margin-top:10px; padding:10px 12px; background:#f6f5ff; border-radius:12px; }
.cc-top-rep-av { width:24px; height:24px; flex:0 0 24px; border-radius:50%; background:#e9e7fd; color:#5B52E0; display:flex; align-items:center; justify-content:center; font-size:11px; font-weight:700; overflow:hidden; }
.cc-top-rep-av img { width:24px !important; height:24px !important; max-width:24px !important; object-fit:cover; padding:0 !important; border:0 !important; }
.cc-top-rep-body { flex:1; min-width:0; }
.cc-top-rep-label { display:flex; align-items:center; gap:6px; font-size:12px; color:#8a8fa3; }
.cc-top-rep-label b { color:#3d454e; font-weight:700; }
.cc-top-rep-score { margin-left:auto; display:inline-flex; align-items:center; gap:2px; color:#1a8f55; font-weight:700; }
.cc-top-rep-text { font-size:14px; line-height:1.45; color:#3d454e; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; word-break:break-word; }

/* 업/다운 투표 */
.cc-vote { display:inline-flex; align-items:center; background:#f4f3fe; border-radius:999px; }
.cc-vbtn { width:36px; height:36px; border:0; background:transparent; border-radius:50%; display:flex; align-items:center; justify-content:center; color:#8a8fa3; cursor:pointer; padding:0; }
.cc-vbtn:hover { background:#e9e7fd; }
.cc-vscore { min-width:22px; text-align:center; font-size:13px; font-weight:700; color:#3d454e; }
.cc-vote.up .cc-vbtn[data-dir="1"] { color:#1a8f55; }
.cc-vote.up .cc-vscore { color:#1a8f55; }
.cc-vote.down .cc-vbtn[data-dir="-1"] { color:#d63c41; }
.cc-vote.down .cc-vscore { color:#d63c41; }
.cc-vote.sm .cc-vbtn { width:32px; height:32px; }
.cc-vbtn:disabled { cursor:default; pointer-events:none; }

/* 질문 상세 팝업 */
#ccViewPopup { max-height:88vh; flex-direction:column; }
#ccViewPopup.cc-show { display:flex !important; }
#ccViewPopup .cc-view-scroll { flex:1; overflow-y:auto; -webkit-overflow-scrolling:touch; padding:12px 16px calc(16px + env(safe-area-inset-bottom)); text-align:left; }
#ccViewPopup .cc-msg-who { font-size:12px; color:#8a8fa3; margin-top:-6px; }
.cc-view-meta { display:flex; justify-content:space-between; font-size:12px; color:#8a8fa3; margin-bottom:8px; }
.cc-view-meta b { font-weight:600; }
.cc-view-text { font-size:17px; line-height:1.55; color:#3d454e; white-space:pre-wrap; word-break:break-word; }
.cc-view-acts { display:flex; align-items:center; gap:10px; margin:10px 0 12px; }

/* 답변 입력 */
.cc-rep-form { background:#f8f9fa; border-radius:16px; padding:10px; }
.cc-rep-row { display:flex; align-items:flex-end; gap:8px; }
.cc-rep-row textarea { flex:1; font-size:16px; resize:none; border-radius:14px; padding:9px 12px; min-height:42px; max-height:120px; line-height:1.4; background:#fff; }
.cc-rep-send { width:42px; height:42px; flex:0 0 42px; border:0; border-radius:50%; display:flex; align-items:center; justify-content:center; padding:0; }
.cc-rep-send:disabled { opacity:.45; cursor:not-allowed; }
.cc-rep-anon { display:flex; align-items:center; gap:8px; min-height:36px; padding:2px 4px 0; }
.cc-rep-anon input { width:18px; height:18px; margin:0; cursor:pointer; }
.cc-rep-anon label { font-size:13px; color:#6c7280; cursor:pointer; }
.cc-rep-bottom { display:flex; align-items:center; gap:8px; margin-top:8px; }
.cc-rep-bottom input { flex:1; width:0; min-width:0; height:42px; font-size:14px; border-radius:12px; }

/* 답변 목록 */
.cc-rep-head { font-size:14px; font-weight:700; color:#3d454e; padding:16px 0 4px; }
.cc-rep { display:flex; gap:10px; padding:12px 0; }
.cc-rep + .cc-rep { border-top:1px solid #f0effa; }
.cc-rep-av { width:24px; height:24px; flex:0 0 24px; border-radius:50%; background:#e9e7fd; color:#5B52E0; display:flex; align-items:center; justify-content:center; font-size:13px; font-weight:700; overflow:hidden; }
.cc-rep-av img { width:24px !important; height:24px !important; max-width:24px !important; object-fit:cover; padding:0 !important; border:0 !important; }
.cc-rep-body { flex:1; min-width:0; }
.cc-rep-top { display:flex; align-items:center; gap:6px; font-size:12px; color:#8a8fa3; }
.cc-rep-name { font-weight:700; color:#3d454e; font-size:13px; }
.cc-rep-owner { background:#766DF4; color:#fff; border-radius:999px; padding:1px 7px; font-size:11px; font-weight:700; }
.cc-rep-text { font-size:15px; line-height:1.5; color:#3d454e; white-space:pre-wrap; word-break:break-word; margin:2px 0 6px; }
.cc-rep-empty { font-size:14px; color:#8a8fa3; padding:8px 0; }

/* 미등록 이름 페이지 */
.cc-un-av { width:120px; height:120px; border-radius:50%; border:2px dashed #b7b2f6; background:#fff; display:inline-flex; align-items:center; justify-content:center; font-size:40px; font-weight:700; color:#b7b2f6; letter-spacing:1px; }
.cc-un-chip { display:inline-block; margin-left:6px; padding:3px 10px; border-radius:999px; background:#fff4e5; color:#8a4b00; font-size:12px; font-weight:700; vertical-align:middle; }

/* 질문 카드 */
.cc-q-card { padding:22px 20px; text-align:left; }
.cc-q-title { font-size:24px; font-weight:800; line-height:1.25; letter-spacing:-.4px; color:#3d454e; margin:0 0 8px; }
.cc-q-sub { font-size:15px; line-height:1.5; color:#6c7280; margin-bottom:16px; }
.cc-q-btn { height:50px; font-size:16px; font-weight:700; display:flex !important; align-items:center; justify-content:center; }

/* 이름 등록 안내 */
.cc-claim { border:1.5px dashed #c9c5f8 !important; background:transparent; padding:16px 18px; text-align:left; }
.cc-claim-top { font-size:12px; font-weight:700; color:#8a8fa3; letter-spacing:.3px; margin-bottom:4px; }
.cc-claim-title { font-size:17px; font-weight:700; color:#3d454e; }
.cc-claim-sub { font-size:14px; color:#6c7280; margin:2px 0 12px; }
.cc-claim-row { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.cc-claim-row .btn { font-weight:700; }
.cc-claim-btn { height:48px; display:flex !important; align-items:center; justify-content:center; font-weight:700; }
.cc-claim-free { border-color:#766DF4 !important; background:#fff !important; }
.cc-claim-paid { font-size:14px; font-weight:600; text-decoration:none; padding:10px 0; }

/* 주제 입력 */
.cc-topic { padding:18px 18px 14px; text-align:left; }
.cc-topic-title { font-size:17px; font-weight:700; color:#3d454e; }
.cc-topic-sub { font-size:14px; color:#6c7280; margin:2px 0 12px; }
.cc-topic-form { display:flex; gap:8px; }
.cc-topic-input { flex:1; min-width:0; display:flex; align-items:center; height:46px; padding:0 14px; border:1.5px solid #e1e0fe; border-radius:999px; background:#fafaff; }
.cc-topic-input:focus-within { border-color:#766DF4; box-shadow:0 0 0 3px rgba(118,109,244,.18); }
.cc-topic-input input { flex:1; min-width:0; border:0; background:transparent; outline:none; font-size:16px; font-weight:600; color:#3d454e; }
.cc-topic-input span { font-size:16px; font-weight:600; color:#766DF4; }
.cc-topic-go { height:46px; padding:0 20px; font-weight:700; }
.cc-topic-ex { font-size:13px; color:#8a8fa3; margin-top:10px; }
.cc-topic-ex a { text-decoration:none; font-weight:600; padding:6px 2px; }

/* 빈 목록 */
.cc-empty { padding:28px 20px; text-align:center; }
.cc-empty-t { font-size:16px; font-weight:700; color:#3d454e; margin-bottom:4px; }
.cc-empty-s { font-size:14px; color:#6c7280; }

/* 정렬 */
.cc-sort-wrap { display:flex; align-items:center; white-space:nowrap; }
.cc-sort-link { color:#6c757d; text-decoration:none; cursor:pointer; font-weight:400; }
.cc-sort-link.active { color:#212529; font-weight:700; }

/* 1차 댓글 정렬 로딩 */
#ccMsgSortLoading { position:absolute; top:0; left:50%; transform:translateX(-50%); width:200px; z-index:100; padding:12px 0; background:transparent; text-align:center; }

/* 2차 댓글 정렬 로딩 */
#ccRepSortLoading { position:absolute; top:0; left:50%; transform:translateX(-50%); width:200px; z-index:100; padding:12px 0; background:transparent; text-align:center; }

/* 작성자 툴팁 */
.cc-author-tooltip { position:absolute; width:250px; max-width:250px; box-sizing:border-box; white-space:normal; overflow-wrap:break-word; word-break:break-word; padding:8px 12px; background:#333; color:#fff; font-size:12px; line-height:1.5; border-radius:5px; z-index:99999; }

/* 상세 팝업 열기 이름의 아이콘 */
#ccViewFrom { display:inline-flex; align-items:center; gap:8px; white-space:nowrap; }

.cc-msg-auto-loading { display:flex; justify-content:center; align-items:center; gap:5px; padding:15px 0; }
.cc-msg-auto-loading span { display:block; width:5px; height:18px; border-radius:3px; background:#adb5bd; animation:ccMsgLoadingMove 0.7s ease-in-out infinite alternate; }
.cc-msg-auto-loading span:nth-child(2) { animation-delay:0.1s; }
.cc-msg-auto-loading span:nth-child(3) { animation-delay:0.2s; }
.cc-msg-auto-loading span:nth-child(4) { animation-delay:0.3s; }
.cc-msg-auto-loading span:nth-child(5) { animation-delay:0.4s; }
@keyframes ccMsgLoadingMove { 0% { transform:translateX(-5px); opacity:0.4; } 100% { transform:translateX(5px); opacity:1; } }

.cc-reply-publishing { color:#999; font-size:12px; }
.cc-reply-unpublished { color:#212529; font-size:12px; cursor:pointer; }


#ccPhotoTooltip input[type="file"] {
        font-size: 12px !important;
}

#ccPhotoTooltip input[type="file"]::file-selector-button {
        font-size: 12px;
        padding: 2px 6px;
        margin-right: 6px;
}

.cc-empty-n{margin-top:6px;color:#766DF4;font-size:12px;font-weight:600;}


@keyframes ccCardDangerBlink {
        0%, 100% {
                border-color: #dc3545;
        }

        50% {
                border-color: transparent;
        }
}

.cc-msg-card.cc-card-danger-blink {
        border: 1px solid #dc3545 !important;
        animation: ccCardDangerBlink 0.7s ease-in-out infinite;
}
</style>



<!-- 하단 고정: 왼쪽 = 내 페이지 서랍 / 오른쪽 비행기 = 글쓰기 레이어 -->
<div class="cc-msg-bar" id="ccMsgBar">
        <button type="button" class="cc-bar-pages" id="ccBarPages" data-bs-toggle="offcanvas" data-bs-target="#ccActivity" aria-controls="ccActivity" aria-label="Pages you're in">
                <span class="cc-bar-ic"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 2 2 7l10 5 10-5-10-5Z"></path><path d="m2 17 10 5 10-5"></path><path d="m2 12 10 5 10-5"></path></svg></span>
                <span class="cc-bar-label">Pages you're in</span>
                <span class="cc-bar-badge" id="ccBarBadge" aria-hidden="true"></span>
        </button>
        <button type="button" class="cc-msg-bar-btn bg-primary" id="ccBarWrite" aria-label="Write something">
                <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M22 2L11 13"></path><path d="M22 2l-7 20-4-9-9-4 20-7z"></path></svg>
        </button>
</div>


<div class="popup-overlay" id="ccMsgOverlay"></div>
<div class="offcanvas-static max-400" id="ccMsgPopup">
        <div class="popup-header-line">
                <div class="popup-address">Write about <span class="cc-name">myperfumecenter</span></div>
                <button type="button" class="btn-close popup-close" id="ccMsgClose" aria-label="Close" style="position:absolute;right:12px;top:10px;"></button>
        </div>
        <div class="popup-body">
                <div id="ccMsgForm">
                        <div class="mb-2">
                                <textarea class="form-control" id="ccMsgText" rows="4" maxlength="500" placeholder="Questions, compliments, or stories about “myperfumecenter”..." autocomplete="off" autocorrect="off" spellcheck="false"></textarea>
                        </div>

                        <div class="mb-2">
                                <input
                                        type="text"
                                        class="form-control"
                                        id="ccReplyName"
                                        maxlength="30"
                                        placeholder="Your name (optional)"
                                        autocomplete="off"
                                >
                        </div>

                        <div class="cc-msg-note">Be respectful. No rumors or personal info.</div>

                        <button type="button" class="btn btn-primary popup-btn-sm rounded-pill" id="ccMsgSend" disabled>Say something</button>
                        <div class="spinner-border text-primary m-1" role="status" id="ccMsgLoading" style="display:none"></div>

                        <div class="cc-msg-who mt-2 text-center" id="ccMsgWho">
                                <a href='https://co.cc/login/login.php'>Google sign-in · Your posts appear higher</a>
                        </div>
                </div>
        </div>
</div>

<!-- ===== 응원 / 싫어요 ===== -->
<script>

function formatScore(score)
{
        score = parseInt(score, 10) || 0;

        var units = [
                { value: 1000000000000, unit: 'T' },
                { value: 1000000000, unit: 'B' },
                { value: 1000000, unit: 'M' },
                { value: 1000, unit: 'K' }
        ];

        for (var i = 0; i < units.length; i++) {

                if (score >= units[i].value) {

                        var result = (score / units[i].value).toFixed(1);

                        result = result.replace(/\.0$/, '');

                        return result + units[i].unit;
                }
        }

        return score.toLocaleString('en-US');
}


        // 내 응원 이름
        var cheerAs = '';

        var HEART_S = '<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"></path></svg>';
        var CHEV = '<svg class="cc-chev" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 6 6 6-6 6"></path></svg>';
        var INFO_S = '<svg class="cc-cheer-info-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"></circle><path d="M12 11v5"></path><path d="M12 8h.01"></path></svg>';

        var shortCodeNo = 0;
        var shortCode = "myperfumecenter";

        // ==================================================
        // 서버 점수 상태
        // ==================================================
        var ccFeel = {
                my_score: 0,
                cheer_score: 0,
                dislike_score: 0,
                loading: true,
                saving: false,

                cheer_user_list: [],

                cheer_list_loading: false,
                cheer_list_loaded: false,
                cheer_list_open: false,

                cheer_list_offset: 0,
                cheer_list_more: true,

                cheerCount: 0,
                tier: 'guest'
        };


        // ==================================================
        // 숫자 표시
        // ==================================================

        function fmt(n) {

                n = parseInt(n, 10) || 0;

                if (n >= 10000) {
                        return Math.round(n / 1000) + 'k';
                }

                if (n >= 1000) {
                        return (n / 1000).toFixed(1).replace(/\.0$/, '') + 'k';
                }

                return String(n);
        }


        // 원본의 버튼 강조 애니메이션
        function pop(el) {
                if (!el) {
                        return;
                }

                $(el).removeClass('pop');

                void el.offsetWidth;

                $(el).addClass('pop');
        }


        // ==================================================
        // 툴팁
        // ==================================================

        // =========================================
        // Tooltip
        // =========================================

        var tipTimer = null;

        function hideTip()
        {
                clearTimeout(tipTimer);
                tipTimer = null;

                $('#ccFeelTip')
                        .removeClass('show')
                        .css({
                                'display': 'none',
                                'visibility': 'hidden',
                                'opacity': 0
                        });
        }



        function showTip(html, btn, ms)
        {
                var $tip = $('#ccFeelTip');

                if (!$tip.length || !btn) {
                        return;
                }

                var card = $tip.closest('.cc-feel-card')[0];

                if (!card) {
                        return;
                }

                clearTimeout(tipTimer);

                $tip
                        .removeClass('show')
                        .html(html)
                        .css({
                                'display': 'block',
                                'visibility': 'hidden',
                                'opacity': 0,
                                'pointer-events': 'auto',
                                'top': 0,
                                'bottom': 'auto',
                                'z-index': 9999
                        });

                var btnRect = btn.getBoundingClientRect();
                var cardRect = card.getBoundingClientRect();

                var top = btnRect.bottom - cardRect.top + card.scrollTop + 6;

                $tip.css('top', top + 'px');

                var tipRect = $tip[0].getBoundingClientRect();

                var arrowX = btnRect.left + (btnRect.width / 2) - tipRect.left;

                var minArrow = 12;
                var maxArrow = tipRect.width - 12;

                arrowX = Math.max(minArrow, Math.min(arrowX, maxArrow));

                $tip[0].style.setProperty('--ax', Math.round(arrowX) + 'px');

                $tip
                        .css({
                                'visibility': 'visible',
                                'opacity': 1
                        })
                        .addClass('show');

                tipTimer = setTimeout(function () {
                        hideTip();
                }, ms || 4000);
        }


        $(document)
                .off('click.ccFeelTip')
                .on('click.ccFeelTip', function (e) {

                        if ($(e.target).closest(
                                '#ccFeelTip, #ccFeel .cc-feel-btn'
                        ).length) {
                                return;
                        }

                        hideTip();
                });



        function tipHtml() {

                var SIGN_IN = '<a href="https://co.cc/login/login.php" class="cc-feel-signin text-info text-decoration-none">Sign in</a>';

                if (ccFeel.tier === 'guest') {
                        return 'You can cheer once a day. ' + SIGN_IN + ' and your cheer counts 2 points 💜';
                }

                if (ccFeel.tier === 'user') {
                        return 'You can cheer once a day. Premium members\' cheers count 10 points.';
                }

                return 'You can cheer once a day. Come back tomorrow!';
        }


        function showFeelFailTip(score, btn)
        {
                // ---- 오늘 이미 응원한 사람이 한 번 더 누르면: 버튼 아래 작은 말풍선 ----
                var message = '';

                if (parseInt(score, 10) == 1) {

                        message = tipHtml();

                } else {

                        message = 'Disliked. You can dislike once a day.';
                }

                showTip(message, btn, 4000);
        }


        // ==================================================
        // 시간순 응원 목록
        // 한 번 응원 = 한 줄
        // 같은 사람이어도 합치지 않음
        // ==================================================

        function renderCheerList()
        {
                /*
                var $l = $('#ccCheerList')
                        .empty()
                        .css('padding-right', '10px');// 스크롤바 가려지는거 방지용
                */

                var $l = $('#ccCheerList')
                        .empty();

                if (!$l.length) {
                        console.error('[CHEER] #ccCheerList element not found');
                        return;
                }

                var users = ccFeel.cheer_user_list || [];


                $.each(users, function (_, c) {

                        var name = $.trim(c.name || '');
                        var nm = name || 'Anonymous';

                        // 응원 시간
                        var time = c.date || '';

                        // 이름 + 시간

                        var $nm = $('<div class="cc-cheer-nm"></div>');

                        if (name) {
                                $nm.html(c.name);
                        } else {
                                $nm.text('Anonymous');
                        }

                        $nm.append(
                                $('<small></small>').text(time)
                        );

                        // 응원 행
                        var $row = $('<div class="cc-cheer-row"></div>')
                                .toggleClass('anon', !name);

                        // 아바타 기본 글자

                        var initial = '?';

                        // HTML 태그 제거 후 첫 글자 추출
                        var plainName = $('<div>').html(name).text().trim();

                        if (plainName) {
                                initial = plainName.substring(0, 1).toUpperCase();
                        }


                        var $avatar = $('<div class="cc-cheer-av"></div>')
                                .text(initial);

                        // Gmail 프로필 이미지
                        var photo = $.trim(c.photo || '');

                        if (photo !== '') {

                                var $img = $('<img>', {
                                        src: photo,
                                        alt: '',
                                        loading: 'lazy'
                                });

                                // 이미지 로딩 실패 시 첫 글자로 복구
                                $img.on('error', function () {
                                        $(this).remove();
                                        $avatar.text(initial);
                                });

                                $avatar.empty().append($img);
                        }

                        $row.append($avatar);

                        $row.append($nm);

                        // 점수 표시
                        $row.append(
                                $('<div class="cc-cheer-pt"></div>')
                                        .toggleClass('m', c.tier === 'primum')
                                        .text('+' + c.score)
                        );

                        $l.append($row);

                });



                // ==================================
                // 목록이 없는 경우
                // ==================================

                if (!users.length && !ccFeel.cheer_list_loading) {

                        $l.append(
                                $('<div>', {
                                        'class': 'cc-cheer-empty',
                                        text: 'No cheers yet.'
                                }).css({
                                        padding: '30px 10px',
                                        color: '#999',
                                        'text-align': 'center',
                                        'font-size': '13px'
                                })
                        );
                }

                // ==================================
                // 더보기 버튼
                // ==================================

                if (ccFeel.cheer_list_more) {

                        var $more = $('<button>', {
                                type: 'button',
                                'class': 'cc-cheer-more',
                                id: 'ccCheerMore'
                        });

                        $more.text(
                                ccFeel.cheer_list_loading
                                        ? 'Loading...'
                                        : 'Show more'
                        );

                        $more.prop('disabled', ccFeel.cheer_list_loading);

                        $l.append($more);

                }



                console.log('[CHEER] render state:', {
                        listLength: (ccFeel.cheer_user_list || []).length,
                        domChildren: $('#ccCheerList').children().length,
                        html: $('#ccCheerList').html()
                });

        }

        // ==================================================
        // 응원자 목록 불러오기 (+1 이상)
        // V 버튼을 눌렀을 때만 호출
        // 20개씩 페이지 조회
        // ==================================================

        function loadCheerUserList(callback, more)
        {
                more = more === true;

                if (ccFeel.cheer_list_loading) {
                        return;
                }

                if (more && !ccFeel.cheer_list_more) {
                        return;
                }

                // 최초 조회
                if (!more) {

                        ccFeel.cheer_list_offset = 0;
                        ccFeel.cheer_list_more = true;
                        ccFeel.cheer_user_list = [];

                }

                ccFeel.cheer_list_loading = true;

                renderCheerList();

                $.ajax({

                        url: 'https://co.cc/reply/short_call_code_cheer_score_info_ajax.php',

                        type: 'POST',

                        dataType: 'json',

                        cache: false,

                        xhrFields: {
                                withCredentials: true
                        },

                        data: {
                                action: 'list',
                                short_code: shortCode,
                                short_code_no: shortCodeNo,
                                offset: ccFeel.cheer_list_offset,
                                limit: 10
                        },

                        success: function (res) {


                                ccLog('loadCheerUserList',res);


                                // 기존 cheerAs가 비어 있을 때만 서버 이름 적용
                                if (
                                        (!cheerAs || $.trim(cheerAs) === '') &&
                                        res.cheer_name &&
                                        $.trim(res.cheer_name) !== ''
                                ) {
                                        cheerAs = $.trim(res.cheer_name);
                                }


                                ccLog('cheer_name',res.cheer_name);

                                if (!res || parseInt(res.proc, 10) !== 1) {

                                        if (!more) {
                                                ccFeel.cheer_user_list = [];
                                                ccFeel.cheer_list_loaded = false;
                                        }

                                        if (typeof callback === 'function') {
                                                callback(false, res);
                                        }

                                        return;
                                }


                                // ==================================
                                // 서버 응답 데이터 확인
                                // ==================================

                                console.log('[CHEER] AJAX response:', res);

                                var data = res.data || res;

                                // 응답 구조별 목록 데이터 추출
                                var users = [];

                                if ($.isArray(data.cheer_user_list)) {

                                        users = data.cheer_user_list;

                                } else if ($.isArray(res.cheer_user_list)) {

                                        users = res.cheer_user_list;

                                } else if ($.isArray(data.users)) {

                                        users = data.users;

                                } else if ($.isArray(data.list)) {

                                        users = data.list;
                                }

                                console.log('[CHEER] users:', users);
                                console.log('[CHEER] #ccCheerList:', $('#ccCheerList').length);



                                // ==================================
                                // +1 이상 응원 기록
                                // ==================================



                                console.log('[CHEER] raw users:', users.length, users[0]);

                                users = $.grep(users, function (user) {
                                        return (parseInt(user.score, 10) || 0) >= 1;
                                });

                                console.log('[CHEER] filtered users:', users.length, users[0]);


                                // ==================================
                                // 기존 목록에 추가
                                // ==================================

                                if (more) {

                                        ccFeel.cheer_user_list =
                                                ccFeel.cheer_user_list.concat(users);

                                } else {

                                        ccFeel.cheer_user_list = users;

                                }


                                // ==================================
                                // 다음 페이지 정보
                                // ==================================

                                ccFeel.cheer_list_offset =
                                        parseInt(data.next_offset, 10) || 0;

                                ccFeel.cheer_list_more =
                                        data.has_more === true ||
                                        data.has_more === 1 ||
                                        data.has_more === '1';


                                // ==================================
                                // 조회 완료
                                // ==================================

                                ccFeel.cheer_list_loaded = true;

                                ccFeel.cheerCount =
                                        ccFeel.cheer_user_list.length;


                                // ==================================
                                // 화면 갱신
                                // ==================================

                                renderCheerFoot();

                                renderCheerList();


                                if (typeof callback === 'function') {
                                        callback(true, res);
                                }

                        },

                        error: function (xhr, status, error) {

                                console.error(
                                        '[CHEER] 응원자 목록 AJAX 오류',
                                        xhr.status,
                                        status,
                                        error
                                );

                                if (!more) {
                                        ccFeel.cheer_list_loaded = false;
                                }

                                if (typeof callback === 'function') {
                                        callback(false);
                                }

                        },

                        complete: function () {

                                ccFeel.cheer_list_loading = false;

                                renderCheerList();

                        }

                });
        }


        function renderCheerFoot()
        {
                // ==================================
                // 0. 내 점수가 0이면 모두 숨김
                // ==================================

                if (ccFeel.my_score === 0) {

                        $('#ccFeelFoot').hide();

                        $('#ccCheerAs').hide();
                        $('#ccCheerBy').hide();
                        $('#ccCheerEdit').hide();
                        $('#ccCheerAsk').hide();

                        closeCheerModal();

                        return;
                }

                // ==================================
                // 1. Footer 표시
                // ==================================

                $('#ccFeelFoot').show();

                // ==================================
                // 2. 내 응원 정보
                // ==================================

                if (ccFeel.my_score < 0) {

                        $('#ccCheerAs').hide();
                        $('#ccCheerEdit').hide();
                        $('#ccCheerAsk').hide();

                } else {

                        $('#ccCheerAsk').show();

                        var $as = $('#ccCheerAs');

                        if (!$('#ccCheerEdit').is(':visible')) {

                                $as.empty().show();

                                if (cheerAs && cheerAs.toLowerCase() !== 'anonymous') {

                                        $as.append('You cheered as ')
                                                .append($('<b></b>').text(cheerAs))
                                                .append(' · ')
                                                .append(
                                                        $('<a>', {
                                                                href: 'javascript:void(0)',
                                                                'class': 'cc-cheer-name-open text-primary text-decoration-none',
                                                                text: 'Change'
                                                        })
                                                );

                                } else {

                                        $as.append('You cheered anonymously · ')
                                                .append(
                                                        $('<a>', {
                                                                href: 'javascript:void(0)',
                                                                'class': 'cc-cheer-name-open text-primary text-decoration-none',
                                                                text: 'Add your name'
                                                        })
                                                );
                                }
                        }
                }

                // ==================================
                // 3. 전체 응원 수 및 응원자 요약
                // ==================================

                var cheerCount = parseInt(ccFeel.cheer_count, 10) || 0;

                var users = ccFeel.cheer_user_list || [];

                var shown = [];
                var seen = {};

                $.each(users, function (i, user) {

                        var name = $.trim(
                                $('<div>').html(user.name || user.cheer_name || '').text()
                        );

                        var key = name.toLowerCase();

                        if (name && !seen[key] && shown.length < 2) {

                                seen[key] = true;
                                shown.push(name);
                        }
                });

                // Bottom Sheet 제목의 응원 수 갱신
                // $('#ccCheerSheetN').text('💜 ' + fmt(cheerCount));
                $('#ccCheerSheetN').text('💜 ' + fmt(ccFeel.cheer_score));

                var $by = $('#ccCheerBy').empty();

                // ==================================
                // 4. 응원자 요약 표시
                // ==================================

                if (cheerCount > 0) {

                        var $summary = $('<span>', {
                                'class': 'cc-cheer-summary'
                        });

                        if (shown.length) {

                                $summary.append('Cheered by ');

                                $.each(shown, function (i, name) {

                                        if (i) {
                                                $summary.append(others > 0 ? ', ' : ' and ');
                                        }

                                        $summary.append(
                                                $('<b></b>').text(name)
                                        );
                                });

                                var others = Math.max(0, cheerCount - shown.length);

                                if (others > 0) {

                                        $summary.append(
                                                ' and ' + fmt(others) +
                                                (others === 1 ? ' other' : ' others')
                                        );
                                }

                        } else {

                                $summary.text(
                                        fmt(cheerCount) +
                                        (cheerCount === 1 ? ' cheer' : ' cheers')
                                );
                        }

                        // ==================================
                        // Bottom Sheet 열기 / 닫기 버튼
                        // ==================================

                        var $toggle = $('<button>', {
                                type: 'button',
                                'class': 'cc-cheer-list-toggle',
                                'aria-label': ccFeel.cheer_list_open
                                        ? 'Collapse cheer list'
                                        : 'Expand cheer list',
                                'aria-expanded': ccFeel.cheer_list_open ? 'true' : 'false'
                        });


                        $toggle.append(
                                $(CHEV).css({
                                        display: 'block',
                                        width: '18px',
                                        height: '18px'
                                })
                        );



                        $by.show().css({
                                display: 'flex',
                                'align-items': 'center',
                                'justify-content': 'space-between',
                                gap: '8px'
                        }).append(HEART_S).append($summary).append($toggle);

                        $summary.css({
                                flex: '1 1 auto'
                        });

                        $toggle.css({
                                display: 'flex',
                                'align-items': 'center',
                                'justify-content': 'center',
                                width: '28px',
                                height: '28px',
                                padding: 0,
                                border: 0,
                                background: 'transparent',
                                color: 'inherit',
                                cursor: 'pointer',
                                'margin-left': 'auto',
                                'flex-shrink': 0
                        });

                } else {

                        $by.hide();

                        // 응원자가 없으면 Bottom Sheet 닫기
                        closeCheerModal();
                }

                // ==================================
                // 5. Footer 상태
                // ==================================

                $('#ccFeelFoot').toggleClass(
                        'none',
                        !cheerCount
                );
        }



        // ==================================================
        // 버튼 화면 표시
        // ==================================================

        function cheerRender() {

                var myScore = parseInt(ccFeel.my_score, 10) || 0;

                var cheerScore = ccFeel.cheer_score;

                var dislikeScore = ccFeel.dislike_score;

                // 서버에서 받은 점수만 표시
                $('#ccFeelCheerN').text(fmt(cheerScore));

                $('#ccFeelDislikeN').text(fmt(dislikeScore));


                // 내가 응원한 적이 있는지
                var cheered = myScore > 0;

                // 내가 싫어요를 준 적이 있는지
                var disliked = myScore < 0;


                var $cheer = $('#ccFeel .cc-feel-btn[data-feel="1"]');

                var $dislike = $('#ccFeel .cc-feel-btn[data-feel="-1"]');


                // 응원 버튼
                $cheer
                        .toggleClass('on', cheered)
                        .toggleClass('done', cheered)
                        .attr('aria-pressed', cheered ? 'true' : 'false')
                        .attr('aria-label', cheered ? 'Cheered' : 'Cheer');


                // 싫어요 버튼
                $dislike
                        .toggleClass('on', disliked)
                        .toggleClass('done', disliked)
                        .attr('aria-pressed', disliked ? 'true' : 'false')
                        .attr('aria-label', disliked ? 'Disliked' : 'Dislike');


                // 조회 또는 저장 중 버튼 잠금
                $('#ccFeel .cc-feel-btn').prop(
                        'disabled',
                        ccFeel.loading || ccFeel.saving
                );

                renderCheerFoot();

        }


        // ==================================================
        // 1. 점수정보 불러오기
        // ==================================================


        function loadCheerScore(callback)
        {
                ccFeel.loading = true;

                cheerRender();

                $.ajax({

                        url: 'https://co.cc/reply/short_call_code_cheer_score_info_ajax.php',

                        type: 'POST',

                        dataType: 'json',

                        cache: false,

                        xhrFields: {
                                withCredentials: true
                        },

                        data: {
                                action: 'info',
                                short_code: shortCode,
                                short_code_no: shortCodeNo
                        },

                        success: function (data) {

                                if (data && data.proc == 1) {

                                        ccFeel.my_score = parseInt(data.my_score, 10) || 0;

                                        // 기존 cheerAs가 비어 있을 때만 서버 이름 적용
                                        if (
                                                (!cheerAs || $.trim(cheerAs) === '') &&
                                                data.cheer_name &&
                                                $.trim(data.cheer_name) !== ''
                                        ) {
                                                cheerAs = $.trim(data.cheer_name);
                                        }

                                        // 점수는 원본 숫자로 유지
                                        ccFeel.cheer_score = parseInt(data.cheer_score, 10) || 0;
                                        ccFeel.dislike_score = parseInt(data.dislike_score, 10) || 0;

                                        // +1 이상 응원 참여 레코드 수
                                        ccFeel.cheer_count = parseInt(data.cheer_count, 10) || 0;

                                        ccLog('ccFeel.cheer_score', ccFeel.cheer_score);
                                        ccLog('ccFeel.dislike_score', ccFeel.dislike_score);

                                        cheerRender();

                                        if (typeof callback === 'function') {
                                                callback(true);
                                        }
                                }
                        },

                        error: function (xhr, status, error) {

                                console.error('[CHEER] 점수정보 AJAX 오류');
                                console.error('HTTP:', xhr.status);
                                console.error('Status:', status);
                                console.error('Error:', error);
                                console.error('Response:', xhr.responseText);

                                showTip('Unable to load score information.');

                                if (typeof callback === 'function') {
                                        callback(false);
                                }
                        },

                        complete: function () {

                                ccFeel.loading = false;

                                // 로딩 해제 후 최종 화면 갱신
                                cheerRender();
                        }
                });
        }



        // ==================================================
        // 2. 점수 주기
        // ==================================================

        function saveCheerScore(score, btn)
        {
                if (ccFeel.loading || ccFeel.saving) {
                        return;
                }

                score = parseInt(score, 10);

                if (score !== 1 && score !== -1) {
                        return;
                }

                // 이미 같은 점수를 준 경우

                if (score === 1 && ccFeel.my_score > 0) {

                        showTip(
                                tipHtml(),
                                btn,
                                6000
                        );

                        return;
                }

                if (score === -1 && ccFeel.my_score < 0) {

                        showTip(
                                'You already disliked today. You can dislike once a day.',
                                btn
                        );

                        return;
                }

                ccFeel.saving = true;
                cheerRender();

                $.ajax({

                        url: 'https://co.cc/reply/short_call_code_cheer_score_save_ajax.php',

                        type: 'POST',

                        dataType: 'json',

                        cache: false,

                        xhrFields: {
                                withCredentials: true
                        },

                        data: {
                                short_code: shortCode,
                                short_code_no: shortCodeNo,
                                name: cheerAs,
                                score: score
                        },


                        success: function (res) {

                                if (!res || parseInt(res.proc, 10) !== 1) {

                                        showTip(
                                                res && res.mssg
                                                        ? res.mssg
                                                        : 'Unable to save your score.',
                                                btn
                                        );

                                        return;
                                }

                                // ==================================
                                // Cheer / Dislike 성공
                                // ==================================


                                if (score === 1) {

                                        // 로그인 여부에 따른 표시 점수
                                        var plus_score = (getCookie('_sgn_')) ? 2 : 1;

                                        // +1 / +2 애니메이션
                                        if (btn) {

                                                var $btn = $(btn);

                                                $btn.find('.cc-plus').remove();

                                                $('<span class="cc-plus">+' + plus_score + '</span>')
                                                        .appendTo($btn);

                                                setTimeout(function () {
                                                        $btn.find('.cc-plus').remove();
                                                }, 800);
                                        }


                                        showTip(
                                                'Cheered! 💜 You can cheer once a day.',
                                                btn,
                                                2500
                                        );

                                }

                                // ==================================
                                // Dislike 성공
                                // ==================================

                                else {

                                        $('#ccCheerPanel').hide();

                                        $('#ccCheerBy').hide();
                                        $('#ccCheerAs').hide();
                                        $('#ccCheerEdit').hide();
                                        $('#ccCheerAsk').hide();

                                        showTip(
                                                'Disliked. You can dislike once a day.',
                                                btn,
                                                2500
                                        );
                                }


                                // ==================================
                                // 응원 목록 초기화
                                // ==================================

                                ccFeel.cheer_list_loaded = false;
                                ccFeel.cheer_list_offset = 0;
                                ccFeel.cheer_list_more = true;
                                ccFeel.cheer_user_list = [];
                                ccFeel.cheerCount = 0;


                                // ==================================
                                // 점수 및 목록 갱신
                                // ==================================
                                loadCheerScore();

                                if (score === 1) {

                                        if (ccFeel.cheer_list_open) {
                                                loadCheerUserList();
                                        } else {
                                                renderCheerList();
                                        }
                                }
                        },

                        error: function () {

                                showTip(
                                        'Unable to save your score.',
                                        btn
                                );

                        },

                        complete: function () {

                                ccFeel.saving = false;

                                cheerRender();

                        }

                });
        }



        // ==================================================
        // 원본 클릭 동작 유지
        // - 응원자 목록 Bottom Sheet 열기 / 닫기
        // - 응원 이름 변경
        // - 친구에게 응원 부탁 (공유 / 링크 복사)
        // ==================================================





        // ==================================================
        // Cheer Bottom Sheet 열기
        // ==================================================

        function openCheerModal()
        {
                var $sheet = $('#ccCheerSheet');

                if (!$sheet.length) {
                        return;
                }

                ccFeel.cheer_list_open = true;

                $('#ccCheerSheetN').text(
                        fmt(parseInt(ccFeel.cheer_count, 10) || 0)
                );

                $('body').addClass('cc-cheer-sheet-open');

                $('#ccCheerOverlay').addClass('show');
                $sheet.addClass('show');

                $('#ccCheerBy .cc-cheer-list-toggle')
                        .attr('aria-expanded', 'true')
                        .attr('aria-label', 'Collapse cheer list');

                if (!ccFeel.cheer_list_loaded && !ccFeel.cheer_list_loading) {

                        loadCheerUserList();

                } else {

                        renderCheerList();
                }
        }


        // ==================================================
        // Cheer Bottom Sheet 닫기
        // ==================================================

        function closeCheerModal()
        {
                ccFeel.cheer_list_open = false;

                $('#ccCheerOverlay').removeClass('show');
                $('#ccCheerSheet').removeClass('show');

                $('body').removeClass('cc-cheer-sheet-open');

                $('#ccCheerBy .cc-cheer-list-toggle')
                        .attr('aria-expanded', 'false')
                        .attr('aria-label', 'Expand cheer list');
        }


        // ==================================================
        // 응원자 목록 버튼 클릭
        // ==================================================

        $(document)
                .off('click.ccCheerList', '#ccCheerBy')
                .on('click.ccCheerList', '#ccCheerBy', function (e) {

                        e.preventDefault();
                        e.stopPropagation();

                        if (ccFeel.cheer_list_open) {
                                closeCheerModal();
                        } else {
                                openCheerModal();
                        }

                });

        // ==================================================
        // Cheer 목록 더보기
        // ==================================================

        $(document)
                .off('click.ccCheerMore', '#ccCheerList #ccCheerMore')
                .on('click.ccCheerMore', '#ccCheerList #ccCheerMore', function (e) {

                        e.preventDefault();
                        e.stopPropagation();

                        if (ccFeel.cheer_list_loading || !ccFeel.cheer_list_more) {
                                return;
                        }

                        var $b = $(this);
                        var $body = $('#ccCheerSheet .cc-cheer-sheet-body');

                        // 현재 스크롤 위치 저장
                        var keep = $body.scrollTop();

                        // 로딩 표시
                        $b.prop('disabled', true).text('Loading…');

                        // 다음 페이지 AJAX 요청
                        loadCheerUserList(function () {

                                // 기존에 보던 스크롤 위치 유지
                                $body.scrollTop(keep);

                        }, true);

                });

        // ==================================================
        // 닫기 버튼
        // ==================================================

        $(document)
                .off('click.ccCheerSheetClose', '#ccCheerSheetClose')
                .on('click.ccCheerSheetClose', '#ccCheerSheetClose', function (e) {

                        e.preventDefault();

                        closeCheerModal();
                });


        // ==================================================
        // 배경 클릭
        // ==================================================

        $(document)
                .off('click.ccCheerSheetOverlay', '#ccCheerOverlay')
                .on('click.ccCheerSheetOverlay', '#ccCheerOverlay', function () {

                        closeCheerModal();
                });


        // ==================================================
        // ESC 닫기
        // ==================================================

        $(document)
                .off('keydown.ccCheerSheet')
                .on('keydown.ccCheerSheet', function (e) {

                        if (e.key === 'Escape' && ccFeel.cheer_list_open) {
                                closeCheerModal();
                        }
                });

        // ==================================================
        // 응원자 목록 버튼 클릭
        // ==================================================

        $(document)
                .off('click.ccCheerList', '#ccCheerBy .cc-cheer-list-toggle')
                .on('click.ccCheerList', '#ccCheerBy .cc-cheer-list-toggle', function (e) {

                        e.preventDefault();
                        e.stopPropagation();

                        openCheerModal();

                });


        // ==================================================
        // 닫기 버튼
        // ==================================================

        $(document)
                .off('click.ccCheerSheetClose', '#ccCheerSheetClose')
                .on('click.ccCheerSheetClose', '#ccCheerSheetClose', function () {

                        closeCheerModal();

                });


        // ==================================================
        // 배경 클릭
        // ==================================================

        $(document)
                .off('click.ccCheerSheetOverlay', '#ccCheerOverlay')
                .on('click.ccCheerSheetOverlay', '#ccCheerOverlay', function () {

                        closeCheerModal();

                });


        // ==================================================
        // ESC 닫기
        // ==================================================

        $(document)
                .off('keydown.ccCheerSheet')
                .on('keydown.ccCheerSheet', function (e) {

                        if (e.key === 'Escape' && ccFeel.cheer_list_open) {
                                closeCheerModal();
                        }

                });

        // ==================================================
        // 응원 이름 입력창 Toggle
        // ==================================================

        function closeNameEdit()
        {
                $('#ccCheerEdit').hide();
                $('#ccCheerAs').show();

                $('#ccCheerName').trigger('blur');

                renderCheerFoot();
        }




        // ==================================================
        // 이름 변경 클릭
        // ==================================================

        $('#ccCheerAs')
                .off('click.ccCheerName')
                .on('click.ccCheerName', '.cc-cheer-name-open', function (e) {

                        e.preventDefault();
                        e.stopPropagation();

                        $('#ccCheerName').val(
                                cheerAs && cheerAs.toLowerCase() !== 'anonymous'
                                        ? cheerAs
                                        : ''
                        );

                        // 기존 툴팁 제거
                        $('#ccCheerNameTooltip').remove();

                        clearTimeout(cheerNameTooltipTimer);

                        // 이름 표시 숨김
                        $('#ccCheerAs').hide();

                        // 입력창 표시
                        $('#ccCheerEdit').css('display', 'flex');

                        $('#ccCheerName').trigger('focus');

                });


        // ==================================================
        // 이름 저장
        // ==================================================

        $('#ccCheerEdit')
                .off('submit.ccCheerName')
                .on('submit.ccCheerName', function (e) {

                        e.preventDefault();

                        ccLog('ccCheerName');

                        var $form = $(this);
                        var $input = $('#ccCheerName');

                        var name = $.trim($input.val());

                        // 중복 전송 방지
                        if ($form.data('saving')) {
                                return;
                        }

                        if (name == '') {
                                showCheerNameTooltip('Please enter your name.');
                                $input.trigger('focus');
                                return;
                        }

                        $form.data('saving', true);

                        $.ajax({

                                url: 'https://co.cc/reply/short_call_code_cheer_change_name_ajax.php',

                                type: 'POST',

                                dataType: 'json',

                                cache: false,

                                xhrFields: {
                                        withCredentials: true
                                },

                                data: {
                                        short_code: shortCode,
                                        short_code_no: shortCodeNo,
                                        name: name
                                },

                                success: function (data) {

                                        ccLog('short_code',shortCode);
                                        ccLog('shortCodeNo',shortCodeNo);


                                        ccLog('ccCheerEdit',data);

                                        if (data && data.proc == 1) {

                                                // 이름 변경 성공
                                                cheerAs = name;

                                                // localStorage 저장
                                                try {

                                                        localStorage.setItem(
                                                                'cc_cheer_name',
                                                                name
                                                        );

                                                } catch (e) {}

                                                // 툴팁 제거
                                                $('#ccCheerNameTooltip').remove();

                                                clearTimeout(cheerNameTooltipTimer);

                                                // 입력창 닫기
                                                closeNameEdit();

                                                // 이름 표시 갱신
                                                renderCheerFoot();

                                                // 성공 팝업
                                                pop(document.getElementById('ccCheerAs'));


                                                // 응원 목록에 영향을 준 경우
                                                if (parseInt(data.cheer_affected, 10) > 0) {
                                                        // 응원 목록 갱신
                                                        ccLog('응원 목록 갱신');
                                                        loadCheerUserList();
                                                }

                                                // 댓글 목록에 영향을 준 경우
                                                if (parseInt(data.reply_affected, 10) > 0) {

                                                        // 댓글 목록 갱신
                                                        ccLog('댓글 목록 갱신');
                                                        loadMsgData();
                                                }

                                        } else {

                                                // 서버 저장 실패
                                                showCheerNameTooltip(
                                                        data && data.mssg
                                                                ? data.mssg
                                                                : 'Failed to change your name.'
                                                );
                                        }

                                },

                                error: function () {

                                        showCheerNameTooltip(
                                                'Unable to change your name. Please try again.'
                                        );

                                },

                                complete: function () {

                                        $form.data('saving', false);

                                }

                        });

                });


        // ==================================================
        // 이름 변경 오류 툴팁
        // ==================================================

        var cheerNameTooltipTimer = null;

        function showCheerNameTooltip(message)
        {
                clearTimeout(cheerNameTooltipTimer);

                $('#ccCheerNameTooltip').remove();

                var $tooltip = $('<div>', {
                        id: 'ccCheerNameTooltip',
                        'class': 'cc-cheer-name-tooltip'
                });

                var $text = $('<span>').text(message);

                var $close = $('<button>', {
                        type: 'button',
                        'class': 'cc-cheer-name-tooltip-close',
                        text: '×'
                });

                $close.on('click', function () {

                        clearTimeout(cheerNameTooltipTimer);

                        $tooltip.remove();

                });

                $tooltip.append($text).append($close);

                $('#ccCheerName').after($tooltip);

                // 5초 후 자동 닫기
                cheerNameTooltipTimer = setTimeout(function () {

                        $tooltip.fadeOut(200, function () {
                                $(this).remove();
                        });

                }, 5000);
        }






        // X 버튼 클릭
        $('#ccCheerEditClose')
                .off('click.ccCheerName')
                .on('click.ccCheerName', function (e) {

                        e.preventDefault();
                        e.stopPropagation();

                        closeNameEdit();

                });


        // ESC 키로 닫기
        $('#ccCheerName')
                .off('keydown.ccCheerName')
                .on('keydown.ccCheerName', function (e) {

                        if (e.key === 'Escape') {

                                e.preventDefault();

                                closeNameEdit();

                        }

                });


        // ---- 친구에게 응원 부탁: 휴대폰은 공유창, PC는 링크 복사 ----

        $('#ccCheerAsk').on('click', function () {

                var url = 'https://' + shortCode + '.co.cc';

                var pageName = (typeof ccPage !== 'undefined' && ccPage.name)
                        ? ccPage.name
                        : shortCode;

                var cheerCount = ccFeel.cheer_score;

                var text = 'Cheer for ' + pageName + ' on co.cc 💜 '
                        + fmt(cheerCount) + ' cheers';

                var $b = $(this);

                if (navigator.share) {

                        navigator.share({
                                title: text,
                                text: text,
                                url: url
                        }).catch(function () {});

                        return;
                }

                if (navigator.clipboard) {

                        navigator.clipboard.writeText(text + ' ' + url).then(function () {

                                var old = $b.html();

                                $b.text('Link copied! Send it to your friends');

                                setTimeout(function () {
                                        $b.html(old);
                                }, 1800);
                        });
                }
        });


        // ==================================================
        // 3. 버튼 이벤트
        // ==================================================

        $('#ccFeel').on('click', '.cc-feel-btn', function () {

                if (ccFeel.loading || ccFeel.saving) {
                        return;
                }

                var score = parseInt($(this).attr('data-feel'), 10);

                saveCheerScore(score, this);

        });



        // ==================================================
        // 페이지 로딩 후 점수정보 조회
        // ==================================================


        $('#ccFeel .cc-feel-btn').prop('disabled', true);

        $('#ccFeelFoot').hide();

        // Bottom Sheet 초기 상태
        $('#ccCheerOverlay').removeClass('show');
        $('#ccCheerSheet').removeClass('show');

        $('body').removeClass('cc-cheer-sheet-open');

        // 이름 입력창 기본 숨김
        $('#ccCheerEdit').hide();

        // 점수 정보만 먼저 조회
        loadCheerScore();


</script>
<!-- ===== /응원 / 싫어요 ===== -->

<script>
// ==================================================
// 콘솔 로그 ON / OFF
// ==================================================
var ccDebug = true;

var ccLog = function() {

        if (!ccDebug) {
                return;
        }

        console.log.apply(console, arguments);
};

var ccMsgMoreAutoClick = false;
var ccMsgMoreAutoLoading = false;

// ==================================================
// HTML 특수문자 이스케이프
// ==================================================
function escapeHtml(value) {

        return $('<div></div>')
                .text(value == null ? '' : String(value))
                .html();
}

$(function () {

        function openMsg() {
                $('#ccReplyName').val(cheerAs);
                $('#ccMsgForm').show(); $('#ccMsgSent').hide();
                $('body').addClass('cc-msg-open');
                $('#ccMsgOverlay').show(); $('#ccMsgPopup').show();
                setTimeout(function () { $('#ccMsgText').trigger('focus'); }, 50);
        }

        window.closeMsg = function() {
                $('#ccMsgOverlay').hide();
                $('#ccMsgPopup').hide();
                $('body').removeClass('cc-msg-open');
                $('#ccMsgText').trigger('blur');
        };


        $('#ccBarWrite').on('click', openMsg);
        $('#ccMsgClose, #ccMsgOverlay').on('click', closeMsg);
        $('#ccMsgAgain, #ccQWrite').on('click', openMsg);

        // 다른 주제로 이동: 글자·숫자·하이픈만 (한글 OK), 공백 제거, 소문자
        function cleanTopic(v) { return String(v).toLowerCase().replace(/\s+/g, '').replace(/[^\p{L}\p{N}-]/gu, '').replace(/^-+|-+$/g, ''); }
        $('#ccTopic').on('input', function () {
                var c = cleanTopic(this.value);
                if (c !== this.value) this.value = c;
                $('.cc-topic-go').prop('disabled', c.length < 2);
        });
        $('#ccTopicForm').on('submit', function (e) {
                e.preventDefault();
                var t = cleanTopic($('#ccTopic').val());
                if (t.length >= 2) location.href = 'https://' + t + '.co.cc';
        });

        // 당사자에게 알려주기: 휴대폰은 공유창, PC는 링크 복사
        $('#ccShareTo').on('click', function () {
                var url = 'https://' + ccPage.slug + '.co.cc';
                var text = 'What do you think about ' + ccPage.name + '?';
                if (navigator.share) { navigator.share({ title: text, text: text, url: url }).catch(function () {}); }
                else if (navigator.clipboard) { navigator.clipboard.writeText(url); $(this).text('Link copied!'); }
        });



});
</script>

<!-- ===== /메시지 남기기 ===== -->
<!-- ===== 메시지 상세 팝업 + 업/다운 투표 + 답변 (추가) ===== -->


<div class="popup-overlay" id="ccViewOverlay"></div>
<div class="offcanvas-static max-400" id="ccViewPopup" role="dialog" aria-labelledby="ccViewTitle">
        <div class="popup-header-line">
                <div class="popup-address" id="ccViewTitle">Message</div>
                <button type="button" class="btn-close popup-close" id="ccViewClose" aria-label="Close" style="position:absolute;right:12px;top:10px;"></button>
        </div>
        <div class="cc-view-scroll" id="ccViewScroll">
                <!-- 1) 질문 -->
                <div class="cc-view-meta"><b id="ccViewFrom"></b><span id="ccViewTime"></span></div>
                <div class="cc-view-text" id="ccViewText"></div>
                <div class="cc-view-acts" id="ccViewActs"></div>

                <!-- 2) 답변 입력 -->

                <div class="cc-rep-form">
                        <!-- 상단: 답변 입력 -->
                        <div class="cc-rep-row">
                                <label for="ccRepText" class="visually-hidden">Write a reply</label>
                                <textarea class="form-control" id="ccRepText" rows="1" maxlength="500" placeholder="Write a reply..."></textarea>
                        </div>

                        <!-- 하단: 이름 입력 + 전송 -->
                        <div class="cc-rep-bottom">
                                <input type="text" class="form-control" id="ccMsgName" maxlength="30" placeholder="Your name (optional)" autocomplete="off">

                                <button type="button" class="cc-rep-send bg-primary" id="ccRepSend" aria-label="Send reply" disabled>
                                        <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
                                                <path d="M22 2L11 13"></path>
                                                <path d="M22 2l-7 20-4-9-9-4 20-7z"></path>
                                        </svg>
                                </button>
                        </div>
                </div>


                <div class="cc-msg-who mt-2 text-center" id="ccMsgWhoReply">
                        <a href='https://co.cc/login/login.php'>Google sign-in · Your posts appear higher</a>
                </div>

                <!-- 2-1) 미등록 페이지: 답변 잠금 안내 -->
                <div class="cc-rep-lock" id="ccRepLock" style="display:none">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#6c7280" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="5" y="11" width="14" height="10" rx="2"></rect><path d="M8 11V7a4 4 0 0 1 8 0v4"></path></svg>
                        <div><div class="cc-rep-lock-t">Only the owner of this name can reply.</div><a href="https://co.cc" class="text-primary fw-semibold">Is this yours? Claim <span class="cc-slug">myperfumecenter</span>.co.cc</a></div>
                </div>

                <!-- 3) 답변 목록 (최신순) -->
                <div class="cc-rep-head" id="ccRepHead">Replies</div>


                <div id="ccRepListWrap" style="position:relative;">

                        <div id="ccRepSortLoading" style="display:none;">
                                <div class="cc-msg-auto-loading">
                                        <span></span>
                                        <span></span>
                                        <span></span>
                                        <span></span>
                                        <span></span>
                                </div>
                                <div class="text-center text-muted small">
                                        Loading ...
                                </div>
                        </div>

                        <div id="ccRepList"></div>

                </div>

        </div>
</div>


<script>

// 실제 서버에서 AJAX로 받아올 데이터
var ccMsgData = [];

// ===== 글 작성자 정보 =====
var ccOwner = {
        name: "myperfumecenter",
        img: "https:\/\/short-img1.cc.cc\/img\/noname.jpg"};


function strip_tags(str)
{
        return String(str).replace(/<[^>]*>/g, '');
}


// ==================================================
// 댓글 기본 조회 / 추가 조회 개수
// ==================================================

// 1차 댓글
var ccMsgVisibleCount = 10;       // 최초 조회
var ccMsgPageSize = 5;            // 스크롤 추가 조회

// 2차 댓글
var ccReplyVisibleCount = 10;     // 최초 조회
var ccReplyPageSize = 5;           // 스크롤 추가 조회


// ==================================================
// 1차 댓글 페이지 상태
// ==================================================

var ccMsgTotalCount = 0;
var ccMsgNextOffset = 0;
var ccMsgHasMore = false;
var ccMsgMoreLoading = false;
// ==================================================
// 2차 댓글 페이지 상태
// ==================================================

var ccReplyTotalCount = 0;
var ccReplyNextOffset = 0;
var ccReplyHasMore = false;
var ccReplyLoading = false;
var ccReplyMoreAutoClick = false;

// 실제 화면에 출력된 대댓글 개수
var ccReplyRenderedCount = 0;

// 2차 댓글 조회 중 새로고침 대기
var ccReplyReloadPending = false;
var ccReplyReloadParentNo = 0;


        // Sort 방식
        var currentRootSort = '';
        var currentReplySort = '';

        var UP = '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 19V5M5 12l7-7 7 7"></path></svg>';
        var DOWN = '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 5v14M19 12l-7 7-7-7"></path></svg>';
        var BUBBLE = '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12a8 8 0 0 1-11.8 7L3 21l2-5.6A8 8 0 1 1 21 12z"></path></svg>';
        var PHOTO = '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="3"></rect><circle cx="9" cy="9" r="2"></circle><path d="M21 15l-5-5L5 21"></path></svg>';


        var current = null;

        var shortCodeNo = 0;
        var shortCode = "myperfumecenter";

        var listUrl = 'https://co.cc/reply/short_call_code_reply_list_ajax.php';
        var saveUrl = 'https://co.cc/reply/short_call_code_reply_save_ajax.php';


        // ==================================================
        // 댓글 데이터 정리
        // ==================================================
        function normalizeMsgData(data) {

                $.each(data, function(i, m) {

                        m.id = parseInt(m.id, 10) || 0;
                        m.score = parseInt(m.score, 10) || 0;
                        m.myVote = parseInt(m.myVote, 10) || 0;

                        m.owner = (m.owner == 1 || m.owner === true);

                        m.from = (m.from == null) ? '' : String(m.from);
                        m.time = m.time || '';
                        m.text = m.text || '';

                        m.replies = m.replies || [];

                        m.reply_count = parseInt(m.reply_count, 10);

                        if (isNaN(m.reply_count)) {
                                m.reply_count = m.replies.length;
                        }

                        $.each(m.replies, function(j, rp) {

                                rp.id = parseInt(rp.id, 10) || 0;
                                rp.score = parseInt(rp.score, 10) || 0;
                                rp.myVote = parseInt(rp.myVote, 10) || 0;

                                rp.owner = (rp.owner == 1 || rp.owner === true);

                                rp.from = (rp.from == null) ? '' : String(rp.from);
                                rp.time = rp.time || '';
                                rp.text = rp.text || '';
                        });
                });

                return data;
        }


        // ==================================================
        // 댓글 데이터 조회
        // 최초 10개만 서버에서 조회
        // ==================================================

        var ccMsgSortRequestNo = 0;

        window.loadMsgData = function(callback) {

                // 이번 요청 고유 번호
                ccMsgSortRequestNo++;

                var requestNo = ccMsgSortRequestNo;

                // 최초 조회 offset
                var requestOffset = 0;

                ccLog('========== 1차 댓글 최초 조회 ==========');


                ccLog('게시물 번호:', shortCodeNo);
                ccLog('게시물 코드:', shortCode);

                ccLog('요청 offset:', requestOffset);
                ccLog('요청 limit:', ccMsgVisibleCount);
                ccLog('요청 root_sort:', currentRootSort);

                // 기존 댓글은 유지하고 로딩만 표시
                $('#ccMsgSortLoading').show();

                // 최초 조회 상태 초기화
                ccMsgNextOffset = 0;
                ccMsgHasMore = false;

                ccMsgMoreLoading = false;
                ccMsgMoreAutoClick = false;
                ccMsgMoreAutoLoading = false;

                $.ajax({
                        url: listUrl,
                        type: 'POST',
                        dataType: 'json',

                        xhrFields: {
                                withCredentials: true
                        },

                        data: {
                                action: 'roots',

                                short_code_no: shortCodeNo,
                                short_code: shortCode,

                                root_sort: currentRootSort,
                                reply_sort: currentReplySort,

                                offset: requestOffset,
                                limit: ccMsgVisibleCount
                        },

                        success: function(res) {

                                ccLog('Reply List',res);

                                // 이전 요청의 응답이면 무시
                                if (requestNo != ccMsgSortRequestNo) {
                                        return;
                                }

                                // 응답 데이터 배열
                                var newData = [];

                                if (res && res.data && $.isArray(res.data)) {
                                        newData = res.data;
                                }

                                ccLog('========== 최초 댓글 서버 응답 ==========');
                                ccLog('전체 응답:', res);
                                ccLog('proc:', res.proc);
                                ccLog('mssg:', res.mssg);
                                ccLog('data:', res.data);
                                ccLog('data 배열 여부:', $.isArray(res.data));
                                ccLog('data 개수:', newData.length);
                                ccLog('has_more:', res.has_more);
                                ccLog('next_offset:', res.next_offset);
                                ccLog('========================================');

                                if (!res || res.proc != 1) {

                                        ccLog('댓글 조회 실패:', res);

                                        // 기존 댓글 유지
                                        if (callback) {
                                                callback(false);
                                        }

                                        return;
                                }

                                // 전체 댓글 수
                                ccMsgTotalCount = parseInt(res.total_count, 10) || 0;

                                // 새 데이터 적용
                                ccMsgData = normalizeMsgData(newData);

                                // 다음 페이지 존재 여부
                                if (typeof res.has_more != 'undefined' && res.has_more !== null) {

                                        ccMsgHasMore = (
                                                res.has_more === true
                                                || res.has_more == 1
                                                || String(res.has_more).toLowerCase() == 'true'
                                        );

                                } else {

                                        ccMsgHasMore = (
                                                ccMsgData.length >= ccMsgVisibleCount
                                        );
                                }

                                // 다음 offset
                                var nextOffset = parseInt(res.next_offset, 10);

                                ccMsgNextOffset = isNaN(nextOffset)
                                        ? ccMsgData.length
                                        : nextOffset;

                                ccLog('최초 조회 댓글 개수:', ccMsgData.length);
                                ccLog('전체 댓글 개수:', ccMsgTotalCount);
                                ccLog('다음 페이지 존재:', ccMsgHasMore);
                                ccLog('다음 offset:', ccMsgNextOffset);

                                // 초기 1차 댓글이 없으면 메시지 헤더 숨김
                                // 헤더 내용만 숨기고 바깥 공간은 유지
                                if (!ccMsgData.length) {
                                        $('.cc-msg-head').addClass('invisible');
                                } else {
                                        $('.cc-msg-head').removeClass('invisible');
                                }


                                // 새 정렬 결과 렌더링
                                renderList();

                                if (callback) {
                                        callback(true);
                                }
                        },

                        error: function(xhr, status, error) {

                                // 이전 요청의 오류이면 무시
                                if (requestNo != ccMsgSortRequestNo) {
                                        return;
                                }

                                ccLog('댓글 조회 오류:', status, error);
                                ccLog('HTTP 상태:', xhr.status);
                                ccLog('응답 내용:', xhr.responseText);

                                // 기존 댓글 유지
                                if (callback) {
                                        callback(false);
                                }
                        },

                        complete: function() {

                                // 가장 최근 요청만 로딩 종료 처리
                                if (requestNo != ccMsgSortRequestNo) {
                                        return;
                                }

                                ccLog('최초 댓글 AJAX 완료');

                                $('#ccMsgSortLoading').hide();
                                $('#ccMsgAutoLoading').hide();

                                ccMsgMoreLoading = false;
                                ccMsgMoreAutoLoading = false;
                                ccMsgMoreAutoClick = false;

                                $(window).trigger('scroll');
                        }
                });
        };


        // ==================================================
        // 1차 댓글 MORE 서버 조회
        // 추가 5개씩 조회
        // ==================================================
        function loadMoreMsgData(isAuto) {

                if (ccMsgMoreLoading || !ccMsgHasMore) {
                        return;
                }

                ccMsgMoreLoading = true;

                if (isAuto) {
                        ccMsgMoreAutoClick = true;
                        ccMsgMoreAutoLoading = true;
                }

                $('#ccMsgAutoLoading').show();

                var requestOffset = ccMsgNextOffset;

                ccLog('========== 1차 댓글 MORE 요청 ==========');
                ccLog('요청 offset:', requestOffset);
                ccLog('요청 limit:', ccMsgPageSize);
                ccLog('현재 댓글 개수:', ccMsgData.length);
                ccLog('요청 root_sort:', currentRootSort);

                $.ajax({
                        url: listUrl,
                        type: 'POST',
                        dataType: 'json',

                        xhrFields: {
                                withCredentials: true
                        },

                        data: {
                                action: 'roots',

                                short_code_no: shortCodeNo,
                                short_code: shortCode,

                                root_sort: currentRootSort,
                                reply_sort: currentReplySort,

                                offset: requestOffset,
                                limit: ccMsgPageSize
                        },

                        success: function(res) {

                                ccLog('========== 1차 댓글 MORE 응답 ==========');
                                ccLog('응답 결과:', res);

                                if (!res || res.proc != 1) {
                                        ccLog('MORE 조회 실패:', res);
                                        return;
                                }

                                var newData = normalizeMsgData(res.data || []);

                                ccLog('추가 조회 댓글 개수:', newData.length);


                                // ==================================================
                                // MORE 서버 응답 상세 확인
                                // ==================================================
                                ccLog('========== MORE 서버 응답 상세 ==========');
                                ccLog('전체 댓글 수:', res.total_count);
                                ccLog('응답 데이터 개수:', newData.length);

                                ccLog('응답 댓글 번호:', $.map(newData, function(m) {
                                        return m.id;
                                }));

                                ccLog('서버 next_offset:', res.next_offset);
                                ccLog('서버 has_more:', res.has_more);
                                ccLog('현재 누적 댓글:', ccMsgData.length);


                                if (!newData.length) {

                                        ccMsgHasMore = false;

                                        ccLog('추가 댓글 없음. MORE 종료');

                                        updateMsgMoreButton();

                                        return;
                                }

                                // 기존 데이터에 추가
                                $.each(newData, function(i, m) {

                                        ccMsgData.push(m);

                                        // 새 댓글만 화면에 추가
                                        appendMsgCard($('#ccMsgList'), m);
                                });

                                // 다음 페이지 정보
                                var nextOffset = parseInt(res.next_offset, 10);

                                ccMsgNextOffset = isNaN(nextOffset)
                                        ? requestOffset + newData.length
                                        : nextOffset;


                                // 다음 페이지 존재 여부
                                if (typeof res.has_more != 'undefined' && res.has_more !== null) {

                                        ccMsgHasMore = (
                                                res.has_more === true
                                                || res.has_more == 1
                                                || String(res.has_more).toLowerCase() == 'true'
                                        );

                                } else {

                                        // 서버에서 has_more를 전달하지 않은 경우
                                        // 이번에 요청한 개수만큼 받았다면 다음 조회 가능성이 있음
                                        ccMsgHasMore = (newData.length >= ccMsgPageSize);
                                }


                                // 전체 1차 댓글 개수 표시
                                var totalCount = parseInt(res.total_count, 10) || 0;

                                $('#ccMsgCount').text('(' + totalCount + ')');


                                updateMsgMoreButton();

                                ccLog('추가 후 전체 로딩 댓글:', ccMsgData.length);
                                ccLog('다음 페이지 존재:', ccMsgHasMore);
                                ccLog('다음 offset:', ccMsgNextOffset);
                        },

                        error: function(xhr, status, error) {

                                ccLog('1차 댓글 MORE AJAX 오류:', status, error);
                                ccLog('HTTP 상태:', xhr.status);
                                ccLog('응답 내용:', xhr.responseText);
                        },

                        complete: function() {

                                $('#ccMsgAutoLoading').hide();

                                ccMsgMoreLoading = false;
                                ccMsgMoreAutoLoading = false;
                                ccMsgMoreAutoClick = false;

                                ccLog('========== 1차 댓글 MORE 완료 ==========');

                                // 다음 댓글이 남아 있으면 현재 스크롤 위치 재확인
                                if (ccMsgHasMore) {

                                        setTimeout(function() {
                                                $(window).trigger('scroll');
                                        }, 150);
                                }
                        }
                });
        }



        // ==================================================
        // 댓글 및 대댓글 저장 공통 함수
        // ==================================================
        function saveMsg(replyText, anon, depth, parentNo, msgName, successCallback, errorCallback) {

                var isSaving = false;


                ccLog('saveMsg 호출 확인:', {
                        time: new Date().toISOString(),
                        depth: depth,
                        parent_no: parentNo,
                        reply: replyText
                });


                // 최초 입력 상태 저장
                var originalReplyText = replyText;

                // Submit 버튼 최초 상태 저장
                var $submitButton = $('#ccQWrite');

                var originalButtonText = $submitButton.html();
                var originalButtonDisabled = $submitButton.prop('disabled');
                var originalButtonClass = $submitButton.attr('class');

                // ==================================================
                // 저장 AJAX
                // ==================================================
                function sendSave(replace) {

                        if (isSaving) {
                                return;
                        }

                        isSaving = true;

                        var postData = {
                                short_code_no: shortCodeNo,
                                short_code: shortCode,
                                anon: anon,
                                reply: replyText,
                                depth: depth,
                                parent_no: parentNo,
                                msg_name: msgName
                        };

                        // 마지막 댓글 교체 요청
                        if (replace) {
                                postData.replace = '1';
                        }



                        var now = new Date();

                        var date =
                                now.getFullYear() + '-' +
                                ('0' + (now.getMonth() + 1)).slice(-2) + '-' +
                                ('0' + now.getDate()).slice(-2) + ' ' +
                                ('0' + now.getHours()).slice(-2) + ':' +
                                ('0' + now.getMinutes()).slice(-2) + ':' +
                                ('0' + now.getSeconds()).slice(-2);

                        ccLog('updated_log 실행', {
                                time: date
                        });


                        $.ajax({
                                url: saveUrl,
                                type: 'POST',
                                dataType: 'json',

                                xhrFields: {
                                        withCredentials: true
                                },

                                data: postData,

                                success: function(res) {

                                        ccLog('댓글 저장', res);

                                        isSaving = false;

                                        // ----------------------------------
                                        // 마지막 댓글 교체 확인 요청
                                        // ----------------------------------
                                        if (
                                                res &&
                                                res.proc != 1 &&
                                                res.data &&
                                                res.data.proc == 'replace_confirm'
                                        ) {

                                                isSaving = false;
                                                showReplaceTooltip();
                                                return;
                                        }

                                        // ----------------------------------
                                        // 저장 실패
                                        // ----------------------------------
                                        if (!res || res.proc != 1) {

                                                if (typeof errorCallback === 'function') {
                                                        errorCallback(res);
                                                }

                                                return;
                                        }

                                        // 저장 성공 콜백
                                        if (typeof successCallback === 'function') {
                                                successCallback(res);
                                        }


                                        window.closeMsg();

                                        // 이름 표시 갱신
                                        if (res.data && typeof res.data.reply_name !== 'undefined') {

                                                cheerAs = res.data.reply_name || '';

                                                ccLog('이름 변경', cheerAs);

                                                // 응원 목록에 영향을 준 경우
                                                if (parseInt(res.data.cheer_affected, 10) > 0) {

                                                        ccLog('응원 목록 갱신: loadCheerUserList()');

                                                        // 이름 수정 영역 닫기
                                                        if ($('#ccCheerEdit').is(':visible')) {

                                                                $('#ccCheerEdit').hide();
                                                        }

                                                        // 응원 목록 갱신
                                                        loadCheerUserList();

                                                }

                                                // 댓글 목록에 영향을 준 경우
                                                if (parseInt(res.data.reply_affected, 10) > 0) {

                                                        ccLog('댓글 목록 갱신: loadMsgData()');

                                                        // 이름 수정 영역 닫기
                                                        if ($('#ccCheerEdit').is(':visible')) {

                                                                $('#ccCheerEdit').hide();
                                                        }

                                                        // 댓글 목록 갱신
                                                        loadMsgData();
                                                }


                                                $('#ccMsgName').val(cheerAs);
                                                // 하단 응원 표시 갱신
                                                ccLog('보이기: renderCheerFoot()');

                                                renderCheerFoot();
                                        }



                                },

                                error: function(xhr, status, error) {

                                        isSaving = false;

                                        if (typeof errorCallback === 'function') {
                                                errorCallback(null);
                                        }

                                }
                        });
                }




                // ==================================================
                // Replace / Cancel 툴팁
                // ==================================================
                function showReplaceTooltip() {


                        $('#ccReplaceTooltip').remove();

                        // 댓글 종류에 따라 실제 버튼 선택
                        var $target;

                        if (parseInt(depth, 10) == 0) {
                                $target = $('#ccMsgSend');
                        } else {
                                $target = $('#ccRepSend');
                        }

                        var $tooltip = $('<div id="ccReplaceTooltip"></div>');

                        $tooltip.css({
                                position: 'fixed',
                                zIndex: 999999,
                                background: '#fff',
                                color: '#222',
                                padding: '10px 12px',
                                border: '1px solid #ddd',
                                borderRadius: '8px',
                                boxShadow: '0 3px 12px rgba(0,0,0,0.18)',
                                fontSize: '13px',
                                lineHeight: '1.5',
                                width: '100%',
                                boxSizing: 'border-box',
                                textAlign: 'left'
                        });

                        var $message = $('<div></div>').text(
                                'Wait for someone else to post, or replace your last post?'
                        );

                        $message.css({
                                marginBottom: '9px'
                        });

                        var $buttons = $('<div></div>').css({
                                display: 'flex',
                                justifyContent: 'flex-end',
                                gap: '8px'
                        });

                        var $replace = $('<button type="button">Replace</button>').css({
                                border: '0',
                                borderRadius: '5px',
                                padding: '6px 13px',
                                background: '#0d6efd',
                                color: '#fff',
                                fontSize: '12px',
                                cursor: 'pointer'
                        });

                        var $cancel = $('<button type="button">Cancel</button>').css({
                                border: '1px solid #ccc',
                                borderRadius: '5px',
                                padding: '6px 13px',
                                background: '#fff',
                                color: '#333',
                                fontSize: '12px',
                                cursor: 'pointer'
                        });

                        $buttons.append($replace, $cancel);
                        $tooltip.append($message, $buttons);

                        $('body').append($tooltip);

                        // ----------------------------------
                        // Send / Submit 버튼의 Y 좌표에 맞춤
                        // ----------------------------------
                        if ($target.length) {

                                var rect = $target[0].getBoundingClientRect();

                                var tooltipWidth = 320;
                                var windowWidth = $(window).width();

                                var tooltipLeft = rect.left + rect.width - tooltipWidth;

                                tooltipLeft = Math.max(5, tooltipLeft);
                                tooltipLeft = Math.min(tooltipLeft, windowWidth - tooltipWidth - 5);

                                $tooltip.css({
                                        left: tooltipLeft + 'px',
                                        top: (rect.top - 20) + 'px',
                                        width: tooltipWidth + 'px',
                                        transform: 'none'
                                });

                        } else {

                                $tooltip.css({
                                        left: '50%',
                                        top: '50%',
                                        transform: 'translate(-50%, -50%)',
                                        width: '300px'
                                });

                        }

                        // ----------------------------------
                        // Replace
                        // ----------------------------------
                        $replace.on('click', function(e) {

                                e.preventDefault();
                                e.stopPropagation();

                                $tooltip.remove();

                                sendSave(true);

                        });
        











                        $cancel.on('click', function(e) {

                                e.preventDefault();
                                e.stopPropagation();

                                // 툴팁 제거
                                $tooltip.remove();

                                // 공통 저장 상태 초기화
                                isSaving = false;

                                // ----------------------------------
                                // 1차 댓글
                                // ----------------------------------
                                if (parseInt(depth, 10) == 0) {

                                        var $replyInput = $('#ccMsgText');
                                        var $nameInput = $('#ccReplyName');
                                        var $anonInput = $('#ccMsgAnon');
                                        var $sendButton = $('#ccMsgSend');

                                        // 로딩 종료
                                        $('#ccMsgLoading').hide();

                                        // 전역 저장 상태 초기화
                                        window.ccRootSaving = false;

                                        // 입력창 활성화 및 기존 내용 유지
                                        $replyInput
                                                .prop('disabled', false)
                                                .prop('readonly', false)
                                                .val(originalReplyText)
                                                .css('pointer-events', 'auto')
                                                .trigger('input');

                                        // 이름 입력창 활성화
                                        $nameInput
                                                .prop('disabled', false)
                                                .prop('readonly', false)
                                                .css('pointer-events', 'auto');

                                        // 익명 체크박스 활성화
                                        $anonInput.prop('disabled', false);

                                        // 댓글 내용이 있으면 버튼 활성화
                                        var hasText = $.trim($replyInput.val()) != '';

                                        $sendButton
                                                .prop('disabled', !hasText)
                                                .removeClass('disabled')
                                                .css('pointer-events', 'auto');

                                }

                                // ----------------------------------
                                // 2차 댓글
                                // ----------------------------------
                                else {

                                        var $replyInput = $('#ccRepText');
                                        var $nameInput = $('#ccMsgName');
                                        var $sendButton = $('#ccRepSend');

                                        // 입력창 활성화 및 기존 내용 유지
                                        $replyInput
                                                .prop('disabled', false)
                                                .prop('readonly', false)
                                                .val(originalReplyText)
                                                .css('pointer-events', 'auto')
                                                .trigger('input');

                                        // 이름 입력창 활성화
                                        $nameInput
                                                .prop('disabled', false)
                                                .prop('readonly', false)
                                                .css('pointer-events', 'auto');

                                        // 댓글 내용이 있으면 버튼 활성화
                                        var hasText = $.trim($replyInput.val()) != '';

                                        $sendButton
                                                .prop('disabled', !hasText)
                                                .removeClass('disabled')
                                                .css('pointer-events', 'auto');

                                }

                        });




                }





                // ----------------------------------
                // Tooltip 닫기
                // ----------------------------------
                function closeReplaceTooltip() {

                        $('#ccReplaceTooltip').remove();

                        $(document).off('click.ccReplaceTooltip');
                        $(window).off('scroll.ccReplaceTooltip');

                        // ----------------------------------
                        // 입력 상태 복구
                        // ----------------------------------
                        if (parseInt(depth, 10) == 0) {

                                $('#ccMsgLoading').hide();

                                window.ccRootSaving = false;

                                $('#ccMsgText').prop('disabled', false);
                                $('#ccReplyName').prop('disabled', false);
                                $('#ccMsgAnon').prop('disabled', false);

                                $('#ccMsgSend').prop(
                                        'disabled',
                                        $.trim($('#ccMsgText').val()) == ''
                                );

                        } else {

                                $('#ccRepText').prop('disabled', false);
                                $('#ccMsgName').prop('disabled', false);

                                $('#ccRepSend').prop(
                                        'disabled',
                                        $.trim($('#ccRepText').val()) == ''
                                );
                        }

                        isSaving = false;
                }

                // ----------------------------------
                // Tooltip 외부 클릭 시 닫기
                // ----------------------------------
                $(document)
                        .off('click.ccReplaceTooltip')
                        .on('click.ccReplaceTooltip', function(e) {

                                if ($(e.target).closest('#ccReplaceTooltip').length) {
                                        return;
                                }

                                closeReplaceTooltip();
                        });

                // ----------------------------------
                // 스크롤 시 닫기
                // ----------------------------------
                $(window)
                        .off('scroll.ccReplaceTooltip')
                        .on('scroll.ccReplaceTooltip', function() {

                                closeReplaceTooltip();
                        });


                // ==================================================
                // 최초 저장 요청
                // ==================================================
                sendSave(false);
        }




        // ==================================================
        // 댓글 다시 작성
        // ==================================================
        $('#ccMsgAgain').on('click', function(e) {

                e.preventDefault();

//                $('#ccMsgSent').hide();
                $('#ccMsgForm').show();

                $('#ccMsgText').val('').prop('disabled', false);

                $('#ccMsgAnon')
                        .prop('checked', false)
                        .prop('disabled', false);

                $('#ccMsgWho').text('Your Google name will be shown.');

                $('#ccMsgSend').prop('disabled', true);

                $('#ccMsgLoading').hide();
        });


        // ==================================================
        // 댓글 입력
        // ==================================================
        $('#ccMsgText')
                .off('input.ccMsgInput')
                .on('input.ccMsgInput', function() {

                var text = $.trim($(this).val());

                $('#ccMsgSend').prop(
                        'disabled',
                        text == '' || text.length > 500
                );
        });


        // ==================================================
        // 댓글 익명 체크
        // ==================================================
        $('#ccMsgAnon')
                .off('change.ccMsgAnon')
                .on('change.ccMsgAnon', function() {

                $('#ccMsgWho').text(
                        this.checked
                                ? 'Your name will be hidden.'
                                : 'Your Google name will be shown.'
                );
        });


        // ==================================================
        // 댓글 저장 실패 툴팁
        // ==================================================
        function showMsgErrorTooltip($target, message) {

                $('.cc-msg-error-tooltip').remove();

                var $tooltip = $('<div></div>')
                        .addClass('cc-author-tooltip cc-msg-error-tooltip')
                        .css({
                                position: 'absolute',
                                zIndex: 999999,
                                paddingRight: '30px'
                        });

                $tooltip.append(
                        $('<span></span>').text(message)
                );

                var $close = $('<span></span>')
                        .text('×')
                        .css({
                                position: 'absolute',
                                top: '3px',
                                right: '8px',
                                cursor: 'pointer',
                                fontSize: '18px',
                                fontWeight: 'bold',
                                lineHeight: '18px'
                        });

                $tooltip.append($close);

                $('body').append($tooltip);

                var offset = $target.offset();

                $tooltip.css({
                        top: offset.top - $tooltip.outerHeight() - 10,
                        left: offset.left + ($target.outerWidth() / 2) - ($tooltip.outerWidth() / 2)
                });


                var timer = setTimeout(function() {

                        $close.trigger('click');

                }, 5000);

                $close.on('click', function(e) {

                        e.preventDefault();
                        e.stopPropagation();

                        clearTimeout(timer);
                        $tooltip.remove();

                });
        }


        // ==================================================
        // 1차 댓글 등록
        // ==================================================

        // 1차 댓글 중복 저장 방지 (스크립트 중복 로딩에도 공유)
        if (typeof window.ccRootSaving === 'undefined') {
                window.ccRootSaving = false;
        }

        $('#ccMsgSend')
                .off('click.ccRootSave')
                .on('click.ccRootSave', function(e) {

                        e.preventDefault();

                        var $btn = $(this);

                        if (window.ccRootSaving) {
                                ccLog('중복 저장 차단');
                                return false;
                        }


                        var replyText = $.trim($('#ccMsgText').val());
                        var msgName = $.trim($('#ccReplyName').val());

                        if (replyText == '') {
                                return false;
                        }

                        if (replyText.length > 500) {
                                showMsgErrorTooltip($btn, 'Please enter up to 500 characters.');
                                return false;
                        }

                        if (msgName.length > 30) {
                                showMsgErrorTooltip($btn, 'Name must be 30 characters or less.');
                                return false;
                        }

                        // 익명 여부
                        var anon = $('#ccMsgAnon').is(':checked') ? 'y' : 'n';

                        ccLog('1차 댓글 전송:', {
                                reply: replyText,
                                msg_name: msgName,
                                anon: anon
                        });

                        // 전송 시작
                        window.ccRootSaving = true;

                        $btn.prop('disabled', true);
                        $('#ccMsgText').prop('disabled', true);
                        $('#ccReplyName').prop('disabled', true);
                        $('#ccMsgAnon').prop('disabled', true);
                        $('#ccMsgLoading').show();

                        saveMsg(
                                replyText,
                                anon,
                                0,
                                0,
                                msgName,
                
                                // 저장 성공
                                function(res) {

                                        $('#ccMsgLoading').hide();

                                        $('#ccMsgText').val('');
                                        $('#ccReplyName').val('');

                                        $('#ccMsgText').prop('disabled', false);
                                        $('#ccReplyName').prop('disabled', false);
                                        $('#ccMsgAnon').prop('disabled', false);

                                        $btn.prop('disabled', true);

                                        window.ccRootSaving = false;
                                        // 최신순으로 변경
                                        currentRootSort = 'newest';

                                        // 댓글 목록 재조회
                                        loadMsgData();
                                },

                                // 저장 실패
                                function(res) {

                                        ccLog('댓글 저장 실패:', res);

                                        $('#ccMsgLoading').hide();

                                        $('#ccMsgText').prop('disabled', false);
                                        $('#ccReplyName').prop('disabled', false);
                                        $('#ccMsgAnon').prop('disabled', false);

                                        $btn.prop('disabled', false);

                                        window.ccRootSaving = false;


                                        var errorMessage = (res && res.mssg)
                                                ? res.mssg
                                                : 'Failed to send message.';

                                        showMsgErrorTooltip($btn, errorMessage);
                                }
                        );

                        return false;
                });


        // ==================================================
        // 댓글 찾기
        // ==================================================
        function findMsg(id) {

                for (var i = 0; i < ccMsgData.length; i++) {

                        if (ccMsgData[i].id === id) {
                                return ccMsgData[i];
                        }
                }

                return null;
        }


        function findRep(m, id) {

                if (!m || !m.replies) {
                        return null;
                }

                for (var i = 0; i < m.replies.length; i++) {

                        if (parseInt(m.replies[i].id, 10) == parseInt(id, 10)) {
                                return m.replies[i];
                        }
                }

                return null;
        }


        // ==================================================
        // 투표 위젯
        // ==================================================


        function voteEl(obj, small) {

                var myVote = parseInt(obj.myVote, 10) || 0;
                var score = parseInt(obj.score, 10) || 0;

                var html = '';

                html += '<div class="cc-vote' + (small ? ' cc-vote-small' : '') + '">';

                // UP 버튼
                var upStyle = (myVote == 1)
                        ? ' style="color:#198754;"'
                        : '';

                html += '<button type="button" class="cc-vbtn" data-dir="1"';
                html += (myVote == 1) ? ' disabled' : '';
                html += '>';
                html += '<span' + upStyle + '>' + UP + '</span>';
                html += '</button>';

                // 점수 (투표 기록이 없으면 0)
                html += '<span class="cc-vscore" style="color:#000;">' + score + '</span>';

                // DOWN 버튼
                var downStyle = (myVote == -1)
                        ? ' style="color:#dc3545;"'
                        : '';

                html += '<button type="button" class="cc-vbtn" data-dir="-1"';
                html += (myVote == -1) ? ' disabled' : '';
                html += '>';
                html += '<span' + downStyle + '>' + DOWN + '</span>';
                html += '</button>';

                html += '</div>';

                return html;
        }

        // ==================================================
        // 투표 UI 개별 갱신
        // ==================================================
        function updateVoteUI(obj) {

                if (!obj || !obj.id) {
                        return;
                }

                var id = parseInt(obj.id, 10);
                var score = parseInt(obj.score, 10) || 0;
                var myVote = parseInt(obj.myVote, 10) || 0;

                // 해당 댓글 카드
                $('#ccMsgList .cc-msg-card').each(function() {

                        if (parseInt($(this).attr('data-id'), 10) == id) {

                                updateVoteElement($(this), score, myVote);
                        }
                });

                // 상세 팝업의 댓글
                if (current && parseInt(current.id, 10) == id) {

                        updateVoteElement($('#ccViewActs'), score, myVote);
                }

                // 해당 대댓글
                $('#ccRepList .cc-rep').each(function() {

                        if (parseInt($(this).attr('data-rid'), 10) == id) {

                                updateVoteElement($(this), score, myVote);
                        }
                });
        }


        // ==================================================
        // 해당 요소의 점수만 갱신
        // ==================================================
        function updateVoteElement(container, score, myVote) {

                container.find('.cc-vote').each(function() {

                        var vote = $(this);

                        // 총점 변경
                        vote.find('.cc-vscore').text(score);

                        // UP / DOWN 버튼 상태 변경
                        vote.find('.cc-vbtn').each(function() {

                                var btn = $(this);
                                var dir = parseInt(btn.attr('data-dir'), 10);
                                var arrow = btn.find('span');

                                if (dir == myVote && myVote != 0) {

                                        btn.prop('disabled', true);

                                        arrow.css(
                                                'color',
                                                dir == 1 ? '#198754' : '#dc3545'
                                        );

                                } else {

                                        btn.prop('disabled', false);
                                        arrow.css('color', '');
                                }
                        });
                });
        }

        // ==================================================
        // 댓글 / 대댓글 점수 저장 AJAX
        // ==================================================
        function applyVote(obj, dir, callback, errorCallback) {

                if (!obj || !obj.id) {
                        return;
                }

                var oldVote = parseInt(obj.myVote, 10) || 0;

                // 이미 투표한 방향이면 아무 반응 없음
                if (oldVote == dir) {
                        return false;
                }

                var nextVote = (dir == 1) ? 1 : -1;

                // 이하 기존 AJAX 저장 코드

                $.ajax({
                        url: 'https://co.cc/reply/short_call_code_reply_score_save_ajax.php',
                        type: 'POST',
                        dataType: 'json',

                        xhrFields: {
                                withCredentials: true
                        },

                        data: {
                                short_code_no: shortCodeNo,
                                short_code: shortCode,
                                reply_no: obj.id,
                                score: nextVote
                        },


                        success: function(res) {

                                ccLog('투표 서버 응답:', res);

                                if (!res || res.proc != 1) {

                                        alert(res && res.mssg ? res.mssg : '점수 저장에 실패했습니다.');

                                        if (errorCallback) {
                                                errorCallback();
                                        }

                                        return;
                                }

                                // 기존 점수
                                var oldScore = parseInt(obj.score, 10) || 0;

                                // 기존 투표와 새로운 투표의 차이만 반영
                                var newScore = oldScore - oldVote + nextVote;

                                // 투표 상태 및 점수 갱신
                                obj.myVote = nextVote;
                                obj.score = newScore;

                                ccLog('점수 변경:', {
                                        oldScore: oldScore,
                                        oldVote: oldVote,
                                        nextVote: nextVote,
                                        newScore: newScore
                                });

                                // 해당 댓글의 투표 UI만 갱신
                                updateVoteUI(obj);

                                if (callback) {
                                        callback(res);
                                }
                        },


                        error: function(xhr, status, error) {

                                ccLog('투표 AJAX 오류:', status, error);
                                ccLog('HTTP 상태:', xhr.status);
                                ccLog('응답:', xhr.responseText);

                                alert('점수 저장 중 오류가 발생했습니다.');

                                if (errorCallback) {
                                        errorCallback();
                                }
                        }
                });
        }



        // ==================================================
        // 대표 2차 댓글
        // PHP에서 전달한 best_reply 우선 사용
        // ==================================================
        function topReply(m) {

                if (!m) {
                        return null;
                }

                // ------------------------------------------
                // PHP에서 조회한 대표 댓글 사용
                // ------------------------------------------
                var best = m.best_reply || null;

                // ------------------------------------------
                // best_reply가 없으면 기존 replies에서 검색
                // ------------------------------------------
                if (!best && m.replies && m.replies.length > 0) {

                        var bestScore = -999999;

                        $.each(m.replies, function(_, rp) {

                                if (rp.reply_stat != 'normal') {
                                        return true;
                                }

                                var score = parseInt(rp.score, 10) || 0;

                                if (!best || score > bestScore) {
                                        best = rp;
                                        bestScore = score;
                                }
                        });
                }

                if (!best) {
                        return null;
                }

                // 비공개 댓글은 대표 댓글로 표시하지 않음
                if (best.reply_stat != 'normal') {
                        return null;
                }

                // ------------------------------------------
                // 내 투표 상태
                // ------------------------------------------
                var myVote = parseInt(best.myVote, 10) || 0;

                best.scoreStyle = 'color:#000 !important;';

                best.showUp = (myVote === 1);
                best.showDown = (myVote === -1);

                best.upColor = best.showUp ? '#198754' : '';
                best.downColor = best.showDown ? '#dc3545' : '';

                return best;
        }



        // ==================================================
        // 대표 답변 표시
        // ==================================================
        function topReplyEl(rp) {

                var myVote = parseInt(rp.myVote, 10) || 0;

                var $av = $('<div class="cc-top-rep-av"></div>');

                if (rp.owner) {

                        $av.append(
                                $('<img alt="">').attr('src', ccOwner.img)
                        );

                } else {


                        if (rp.from === 'Anonymous')
                        {
                                $av.text('?');
                        }
                        else
                        {
                                if (rp.from_img)
                                {
                                        $av.append(
                                                $('<img alt="">').attr('src', rp.from_img)
                                        );
                                }
                                else
                                {
                                        var from_strip = strip_tags(rp.from).trim();
                                        $av.text(from_strip.charAt(0).toUpperCase());
                                }
                        }

                }

                var $label = $('<div class="cc-top-rep-label"></div>')
                        .append($('<b></b>').html(rp.from));

                if (rp.owner) {
                        $label.append('<span class="cc-rep-owner">Owner</span>');
                }

                var $score = $('<span class="cc-top-rep-score" aria-label="Top reply score"></span>');

                // 내가 UP을 준 경우
                if (myVote === 1) {

                        $score.append(
                                $('<span></span>')
                                        .css({
                                                color: '#198754',
                                                display: 'inline-flex'
                                        })
                                        .html('<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 19V5M5 12l7-7 7 7"></path></svg>')
                        );

                // 내가 DOWN을 준 경우
                } else if (myVote === -1) {

                        $score.append(
                                $('<span></span>')
                                        .css({
                                                color: '#dc3545',
                                                display: 'inline-flex'
                                        })
                                        .html('<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 5V19M19 12l-7 7-7-7"></path></svg>')
                        );
                }

                // 점수는 항상 검정색
                $score.append(
                        $('<span></span>')
                                .css('color', '#000')
                                .text(parseInt(rp.score, 10) || 0)
                );

                $label.append($score);



               var $body = $('<div class="cc-top-rep-body"></div>');

               $body.append($label);

                // TOP 댓글 내용
                var $topText = $('<div class="cc-top-rep-text"></div>');

                // 사진 아이콘
                if (rp.photo_src) {

                        $topText.append(
                                $('<span class="cc-photo-icon" title="Photo attached"></span>')
                                        .text('📷')
                                        .css({
                                                display: 'inline',
                                                marginRight: '5px',
                                                fontSize: '13px'
                                        })
                        );
                }

                // 댓글 텍스트
                $topText.append(
                        $('<span></span>').text(rp.text)
                );

                $body.append($topText);

               return $('<div class="cc-top-rep"></div>')
                       .append($av)
                       .append($body);
        }

        // ==================================================
        // See all messages 표시 여부
        // ==================================================
        function updateMsgMoreButton() {

                if (ccMsgHasMore) {
                        $('#ccMsgMoreWrap').removeClass('d-none').show();
                } else {
                        $('#ccMsgMoreWrap').addClass('d-none').hide();
                }
        }


        // ==================================================
        // 1차 댓글 카드의 2차 댓글 수만 갱신
        // ==================================================
        function updateRootReplyCount(parentNo, count) {

                parentNo = parseInt(parentNo, 10);
                count = parseInt(count, 10) || 0;

                // 내부 데이터 갱신
                var m = findMsg(parentNo);

                if (m) {
                        m.reply_count = count;
                }

                // 현재 화면에 표시된 해당 카드만 갱신
                $('#ccMsgList .cc-msg-card').each(function() {

                        var $card = $(this);

                        if (parseInt($card.attr('data-id'), 10) == parentNo) {

                                $card.find('.cc-reply-count').text(count);

                                return false;
                        }
                });
        }



        // ==================================================
        // 댓글 카드 생성
        // ==================================================
        function appendMsgCard($list, m) {

                var replyId = parseInt(m.id, 10) || 0;

                if (replyId <= 0) {
                        return;
                }

                // 이미 화면에 출력된 댓글이면 추가하지 않음
                if ($list.find('.cc-msg-card[data-id="' + replyId + '"]').length > 0) {
                        ccLog('중복 1차 댓글 출력 차단:', replyId);
                        return;
                }

                var $card = $('<div class="card bg-white card-fixed-width cc-msg-card" role="button" tabindex="0"></div>')
                        .attr('data-id', replyId);


                // 작성자 아바타
                var $av = $('<div class="cc-rep-av"></div>');

                if (m.from_img) {

                        $av.append(
                                $('<img>').attr('src', m.from_img)
                        );

                } else {

                        var fromText = $('<div></div>').html(m.from).text().trim();
                        var firstChar = 'A';

                        if (fromText.toLowerCase() == 'anonymous') {
                                firstChar = '?';
                        } else if (fromText) {
                                firstChar = fromText.substring(0, 1).toUpperCase();
                        }

                        $av.text(firstChar);
                }


                // 작성자 정보
                var $meta = $('<div class="cc-msg-meta"></div>');

                $meta.append(
                        $('<div class="d-flex align-items-center gap-2"></div>')
                                .append($av)
                                .append($('<span></span>').html(m.from))
                );


                // ==================================================
                // 작성 시간 표시
                // ==================================================
                var timeHtml = '';

                if (m.reply_stat == '') {

                        timeHtml = $('<span class="cc-reply-publishing"></span>')
                                .text('Publishing…');

                } else if (m.reply_stat != 'normal') {

                        timeHtml = $('<span class="cc-reply-unpublished"></span>')
                                .text('Unpublished');

                        // Unpublished 클릭 이벤트
                        timeHtml.on('click', function(e) {

                                e.preventDefault();
                                e.stopPropagation();

                                showReportMessageTooltip(
                                        $(this),
                                        'This post may make others feel uncomfortable, so it hasn’t been published yet.'
                                );

                                return false;
                        });

                } else {

                        timeHtml = $('<span></span>')
                                .text(m.time);
                }

                $meta.append(timeHtml);

                $card.append($meta);


                // ==================================================
                // 댓글 내용
                // ==================================================
                var $msgText = $('<div class="cc-msg-text cc-msg-clamp posting-text-color"></div>');

                $msgText.append(
                        $('<span></span>').text(m.text)
                );

                $card.append($msgText);


                // 대표 2차 댓글
                var best = topReply(m);

                if (best) {
                        $card.append(topReplyEl(best));
                }


                // ==================================================
                // 댓글 하단 영역
                // ==================================================
                var $foot = $('<div class="cc-msg-foot"></div>');

                $foot.append(voteEl(m, true));

                var replyCount = parseInt(m.reply_count, 10) || 0;

                // 2차 댓글 수
                $foot.append(
                        $('<span class="cc-stat" aria-label="Replies"></span>')
                                .html(
                                        BUBBLE +
                                        '<span class="cc-reply-count">' +
                                        replyCount +
                                        '</span>'
                                )
                );



                // ==================================================
                // 사진 개수 표시
                // ==================================================
                var photoCount = parseInt(m.photo_count, 10) || 0;

                if (photoCount > 0) {

                        var $photoStat = $('<span class="cc-stat cc-photo-stat" aria-label="Photos"></span>')
                                .attr('data-rid', m.id);

                        $photoStat.append(
                                $(PHOTO).css({
                                        width: '18px',
                                        height: '18px',
                                        flexShrink: 0
                                })
                        );

                        $photoStat.append(
                                $('<span class="cc-photo-count"></span>')
                                        .text(photoCount)
                        );

                        $foot.append($photoStat);
                }


                // ==================================================
                // 1차 댓글 Photo / Delete 버튼
                // ==================================================

                var canDelete = (
                        parseInt(m.can_delete, 10) == 1
                        || m.can_delete === true
                );


                var canPhoto = (
                        parseInt(m.can_photo, 10) == 1
                        || m.can_photo === true
                );

                var hasPhoto = (
                        canPhoto
                        && m.reply_stat != 'unpublished'
                );


                // Photo 버튼
                if (hasPhoto) {

                        $foot.append(
                                makeReplyPhotoButton(m).css({
                                        marginLeft: 'auto',
                                        marginRight: '20px',
                                        whiteSpace: 'nowrap',
                                        flexShrink: 0
                                })
                        );
                }


                // Delete 버튼
                if (canDelete) {

                        $foot.append(
                                $('<a></a>')
                                        .attr('href', '#')
                                        .addClass('cc-reply-delete text-danger small')
                                        .attr('data-rid', replyId)
                                        .css({
                                                marginLeft: hasPhoto ? '0' : 'auto',
                                                whiteSpace: 'nowrap',
                                                flexShrink: 0,
                                                fontWeight: 'normal',
                                                fontSize: '85%'
                                        })
                                        .text('Delete')
                        );
                }


                $card.append($foot);


                $list.append(
                        $('<div class="d-flex justify-content-center mb-2"></div>')
                                .append($card)
                );
        }



        // ==================================================
        // Unpublished 안내 툴팁
        // 1차 댓글 / 상세창 1차 댓글 / 2차 댓글 공통 적용
        // ==================================================
        $(document)
                .off('click.ccReplyUnpublished')
                .on('click.ccReplyUnpublished', '.cc-reply-unpublished', function(e) {

                        e.preventDefault();
                        e.stopPropagation();
                        e.stopImmediatePropagation();

                        showReportMessageTooltip(
                                $(this),
                                'This post may make others feel uncomfortable, so it hasn’t been published yet.'
                        );

                        return false;
                });


        // ==================================================
        // 댓글 신고 버튼 클릭
        // ==================================================
        $(document)
                .off('click.ccReplyReport', '.cc-reply-report')
                .on('click.ccReplyReport', '.cc-reply-report', function(e) {

                        e.preventDefault();
                        e.stopPropagation();
                        e.stopImmediatePropagation();

                        var $reportBtn = $(this);
                        var replyNo = parseInt($reportBtn.attr('data-rid'), 10);

                        if (isNaN(replyNo) || replyNo <= 0) {
                                return false;
                        }

                        $reportBtn.css('pointer-events', 'none');

                        $.ajax({

                                url: 'https://co.cc/reply/short_call_code_reply_report_save_ajax.php',

                                type: 'POST',

                                dataType: 'json',

                                xhrFields: {
                                        withCredentials: true
                                },

                                data: {
                                        short_code_no: shortCodeNo,
                                        short_code: shortCode,
                                        reply_no: replyNo
                                },

                                success: function(res) {

                                        if (res && parseInt(res.proc, 10) == 1) {

                                                showMsgErrorTooltip(
                                                        $reportBtn,
                                                        res.mssg ? res.mssg : 'Thank you for your report.'
                                                );

                                        } else {

                                                showMsgErrorTooltip(
                                                        $reportBtn,
                                                        res && res.mssg
                                                                ? res.mssg
                                                                : 'Failed to submit report.'
                                                );
                                        }
                                },

                                error: function(xhr, status, error) {

                                        ccLog('Report AJAX error:', error);
                                        ccLog(xhr.responseText);

                                        showMsgErrorTooltip(
                                                $reportBtn,
                                                'Failed to submit report. Please try again.'
                                        );
                                },

                                complete: function() {

                                        $reportBtn.css('pointer-events', '');
                                }
                        });

                        return false;
                });


        // ==================================================
        // 댓글 목록 그리기
        // ==================================================
        function renderList() {

                var $list = $('#ccMsgList').empty();

                // 기존 빈 댓글 안내 카드 제거 (중복 방지)
                $('#ccQEmptyWrap').remove();

                // 전체 1차 댓글 개수 표시
                $('#ccMsgCount').text('(' + ccMsgTotalCount + ')');

                // 댓글이 없으면 헤더와 더보기 숨김
                $('#ccMsgHeadWrap, #ccMoreWrap').toggleClass('d-none', ccMsgData.length === 0);

                var shortCodeText = "myperfumecenter";

                if (ccMsgData.length) {
                } else {
                        // ==================================================
                        // 댓글이 없을 때
                        // ==================================================

                        $('#ccMsgHeadWrap, #ccMoreWrap').addClass('d-none');

                        // 기존 빈 댓글 카드 제거
                        $('#ccQEmptyWrap').remove();


                        // 빈 댓글 안내 카드 생성
                        var $e = $('<div class="card bg-white card-fixed-width cc-empty" role="button" tabindex="0"></div>')
                                .append('<div class="cc-empty-t">No posts yet</div>')
                                .append(
                                        $('<div class="cc-empty-s"></div>')
                                                .text('Be the first to say something about “' + shortCodeText + '“.')
                                                .append('<div class="cc-empty-n">Anonymous · No login required</div>')
                                );

                        // 댓글 목록 바로 앞에 표시
                        $('#ccMsgList').before(
                                $('<div id="ccQEmptyWrap" class="d-flex justify-content-center mb-2"></div>')
                                        .append($e)
                        );

                        return;
                }

                // 댓글이 있을 때
                $('#ccMsgHeadWrap, #ccMoreWrap').removeClass('d-none');
                $('#ccQEmptyWrap').remove();

                // ==================================================
                // 1차 댓글 정렬 상태 표시
                // ==================================================
                updateRootSortUI();

                // 표시 개수 보정
                ccMsgVisibleCount = Math.min(
                        ccMsgVisibleCount,
                        ccMsgData.length
                );

                // 서버에서 받아온 댓글 전체 출력
                for (var i = 0; i < ccMsgData.length; i++) {

                        appendMsgCard($list, ccMsgData[i]);
                }

                // 추가 댓글이 있는 경우에만 버튼 표시
                updateMsgMoreButton();
        }


        // ==================================================
        // 1차 댓글 데이터 찾기
        // ==================================================
        function getRootMsgData(rootNo) {

                rootNo = parseInt(rootNo, 10) || 0;

                for (var i = 0; i < ccMsgData.length; i++) {

                        if (parseInt(ccMsgData[i].id, 10) == rootNo) {
                                return ccMsgData[i];
                        }
                }

                return null;
        }

        // ==================================================
        // 1차 댓글 정렬 상태 표시
        // ==================================================

        function updateRootSortUI() {

                $('#ccMsgTop').toggleClass(
                        'active',
                        currentRootSort != 'newest'
                );

                $('#ccMsgNewest').toggleClass(
                        'active',
                        currentRootSort == 'newest'
                );
        }


        // ==================================================
        // 2차 댓글 정렬 상태 표시
        // ==================================================

        function updateReplySortUI() {

                $('#ccRepTop').toggleClass(
                        'active',
                        currentReplySort != 'newest'
                );

                $('#ccRepNewest').toggleClass(
                        'active',
                        currentReplySort == 'newest'
                );
        }


        // ==================================================
        // See all messages 클릭 이벤트
        // ==================================================

ccLog('전체 데이터:', ccMsgData.length);
ccLog('화면 댓글:', $('#ccMsgList .cc-msg-card').length);
ccLog('버튼 표시:', $('#ccMsgMoreWrap').css('display'));

        // ==================================================
        // 1차 댓글 Top
        // ==================================================

        $(document)
                .off('click.ccMsgTop', '#ccMsgTop')
                .on('click.ccMsgTop', '#ccMsgTop', function(e) {

                        e.preventDefault();
                        e.stopPropagation();

                        if (currentRootSort == '') {
                                return false;
                        }

                        currentRootSort = '';

                        updateRootSortUI();

                        loadMsgData();

                        return false;
                });


        // ==================================================
        // 2차 댓글 Top
        // ==================================================

        $(document)
                .off('click.ccRepTop', '#ccRepTop')
                .on('click.ccRepTop', '#ccRepTop', function(e) {

                        e.preventDefault();
                        e.stopPropagation();

                        var parentNo = parseInt($(this).attr('data-parent-no'), 10);

                        if (!parentNo) {
                                return false;
                        }

                        currentReplySort = '';

                        loadMsgDataAfterReply(parentNo);

                        return false;
                });


        // ==================================================
        // 1차 댓글 Bottom Scroll 자동 추가
        // ==================================================
        function ccMsgCheckBottom() {

                if (ccMsgMoreAutoClick || ccMsgMoreLoading || !ccMsgHasMore) {
                        return;
                }

                var $more = $('#ccMsgMoreWrap');

                if (!$more.length || $more.hasClass('d-none')) {
                        return;
                }

                var scrollBottom = $(window).scrollTop() + $(window).height();

                var triggerPosition = $more.offset().top - 200;

                if (scrollBottom < triggerPosition) {
                        return;
                }

                ccLog('1차 댓글 하단 도달 - MORE 자동 조회');

                loadMoreMsgData(true);
        }


        // ==================================================
        // 1차 댓글 스크롤 이벤트
        // ==================================================
        $(window)
                .off('scroll.ccMsgAutoMore')
                .on('scroll.ccMsgAutoMore', function() {

                        ccMsgCheckBottom();
                });



        // ==================================================
        // 1차 댓글 최신순 정렬
        // ==================================================

        $(document)
                .off('click.ccMsgNewest', '#ccMsgNewest')
                .on('click.ccMsgNewest', '#ccMsgNewest', function(e) {

                        e.preventDefault();
                        e.stopPropagation();

                        if (currentRootSort == 'newest') {
                                return false;
                        }

                        currentRootSort = 'newest';

                        updateRootSortUI();

                        loadMsgData();

                        return false;
                });


        // ==================================================
        // 1차 댓글 MORE 버튼
        // 서버에서 추가 5개 조회
        // ==================================================
        $(document)
                .off('click.ccMsgMore')
                .on('click.ccMsgMore', '#ccMsgMoreWrap .cc-msg-more', function(e) {

                        e.preventDefault();
                        e.stopPropagation();

                        ccLog('1차 댓글 MORE 버튼 클릭');

                        loadMoreMsgData(false);

                        return false;
                });

        // ==================================================
        // 목록 화면 투표 이벤트
        // ==================================================
        $('#ccMsgList').on('click', '.cc-vbtn', function(e) {

                e.stopPropagation();

                var $btn = $(this);

                var $card = $btn.closest('.cc-msg-card');

                var m = findMsg(
                        parseInt($card.attr('data-id'), 10)
                );

                if (!m) {
                        return;
                }

                var dir = parseInt($btn.attr('data-dir'), 10);

                $btn.prop('disabled', true);

                applyVote(m, dir);
        });




        // ==================================================
        // 상세 팝업 투표 및 신고 버튼
        // ==================================================
        function renderViewVote() {

                if (!current) {
                        return;
                }

                var $actions = $('<div></div>').css({
                        display: 'flex',
                        alignItems: 'center',
                        width: '100%'
                });

                $actions.append($(voteEl(current)));

                // ==================================================
                // 권한 확인
                // ==================================================

                var canDelete = (
                        parseInt(current.can_delete, 10) == 1
                        || current.can_delete === true
                );

                var canReport = (
                        parseInt(current.can_report, 10) == 1
                        || current.can_report === true
                );

                var canPhoto = (
                        parseInt(current.can_photo, 10) == 1
                        || current.can_photo === true
                );

                // Published 상태이며 Photo 권한이 있는 댓글만 표시
                var hasPhoto = (
                        canPhoto
                        && current.reply_stat != 'unpublished'
                );

                // ==================================================
                // Photo 버튼
                // ==================================================

                if (hasPhoto) {

                        $actions.append(
                                makeReplyPhotoButton(current).css({
                                        marginLeft: 'auto',
                                        marginRight: canDelete ? '20px' : '0',
                                        whiteSpace: 'nowrap',
                                        flexShrink: 0
                                })
                        );
                }

                // ==================================================
                // Delete 버튼
                // ==================================================

                if (canDelete) {

                        $actions.append(
                                $('<a></a>')
                                        .attr('href', '#')
                                        .addClass('cc-reply-delete text-danger small')
                                        .attr('data-rid', current.id)
                                        .css({
                                                marginLeft: hasPhoto ? '0' : 'auto',
                                                whiteSpace: 'nowrap',
                                                flexShrink: 0,
                                                fontWeight: 'normal',
                                                fontSize: '85%'
                                        })
                                        .text('Delete')
                        );

                } else if (canReport && !isReplyReported(current)) {

                        var $reportAction = makeReplyReportAction(current);

                        if ($reportAction) {
                                $actions.append($reportAction);
                        }
                }

                // ==================================================
                // 출력
                // ==================================================

                $('#ccViewActs').empty().append($actions);

                normalizeReplyReportButtons($('#ccViewActs'));
        }



        // ==================================================
        // 신고 상태 확인
        // ==================================================
        function isReplyReported(obj) {

                if (!obj) {
                        return false;
                }

                var value = obj.my_report;

                return (
                        value === true
                        || value === 'true'
                        || value === 'y'
                        || value === 'Y'
                        || value === 'yes'
                        || parseInt(value, 10) > 0
                );
        }


        // ==================================================
        // Report / Reported 중복 제거
        // ==================================================
        function normalizeReplyReportButtons($container) {

                if (!$container || !$container.length) {
                        return;
                }

                $container.find('.cc-reply-reported').each(function() {

                        var replyNo = $(this).attr('data-rid');

                        if (!replyNo) {
                                return;
                        }

                        $container.find('.cc-reply-report').each(function() {

                                if (
                                        String($(this).attr('data-rid'))
                                        === String(replyNo)
                                ) {
                                        $(this).remove();
                                }
                        });
                });
        }


        // ==================================================
        // 신고 버튼 생성
        // 신고 완료 상태이면 아무것도 표시하지 않음
        // ==================================================
        function makeReplyReportAction(obj) {

                if (isReplyReported(obj)) {
                        return null;
                }

                return $('<a></a>')
                        .attr('href', '#')
                        .addClass('cc-reply-report text-secondary small')
                        .attr('data-rid', obj.id)
                        .css({
                                marginLeft: 'auto',
                                whiteSpace: 'nowrap',
                                flexShrink: 0,
                                fontWeight: 'normal',
                                fontSize: '85%'
                        })
                        .text('Report');
        }




        // ==================================================
        // 신고 툴팁 위치
        // Report 클릭 위치를 툴팁 오른쪽 끝에 맞춤
        // 상세 팝업 좌우 경계 제한
        // ==================================================
        function positionReportTooltip($tooltip, $target) {

                if (!$target || !$target.length) {
                        return;
                }

                var targetOffset = $target.offset();

                var targetRight = targetOffset.left + $target.outerWidth();

                var tooltipWidth = $tooltip.outerWidth();
                var tooltipHeight = $tooltip.outerHeight();

                var left = targetRight - tooltipWidth;
                var top = targetOffset.top - tooltipHeight - 9;

                var $popup = $('#ccViewPopup');

                if ($popup.length && $popup.is(':visible')) {

                        var popupOffset = $popup.offset();

                        var popupLeft = popupOffset.left + 8;
                        var popupRight = popupOffset.left + $popup.outerWidth() - 8;

                        var minLeft = popupLeft;
                        var maxLeft = popupRight - tooltipWidth;

                        if (maxLeft < minLeft) {
                                maxLeft = minLeft;
                        }

                        left = Math.max(minLeft, Math.min(left, maxLeft));
                }

                if (top < $(window).scrollTop() + 5) {
                        top = targetOffset.top + $target.outerHeight() + 9;
                }

                $tooltip.css({
                        position: 'absolute',
                        zIndex: 999999,
                        top: top,
                        left: left
                });
        }


        // ==================================================
        // 안내 툴팁 표시
        // 바깥 클릭 또는 스크롤 시 닫기
        // ==================================================
        function showReportMessageTooltip($target, message) {

                // 기존 툴팁 및 이벤트 제거
                $('.cc-report-tooltip').remove();

                $(window).off('.ccReportTooltip');
                $(document).off('.ccReportTooltip');

                if (!$target || !$target.length) {
                        return;
                }

                var $tooltip = $('<div></div>')
                        .addClass('cc-author-tooltip cc-report-tooltip')
                        .css({
                                position: 'absolute',
                                zIndex: 999999,
                                display: 'block',
                                maxWidth: 'min(280px, calc(100vw - 24px))',
                                boxSizing: 'border-box',
                                padding: '9px 12px',
                                background: '#212529',
                                color: '#fff',
                                border: '1px solid rgba(255,255,255,.1)',
                                borderRadius: '8px',
                                boxShadow: '0 3px 14px rgba(0,0,0,.2)',
                                whiteSpace: 'normal',
                                overflowWrap: 'anywhere'
                        });

                $tooltip.append(
                        $('<span></span>').text(message)
                );

                $('body').append($tooltip);

                // ==================================================
                // 툴팁 위치 계산
                // ==================================================
                var offset = $target.offset();

                var left = offset.left
                        + $target.outerWidth()
                        - $tooltip.outerWidth();

                var top = offset.top
                        - $tooltip.outerHeight()
                        - 8;

                left = Math.max(
                        5,
                        Math.min(
                                left,
                                $(window).width() - $tooltip.outerWidth() - 5
                        )
                );

                // 화면 위쪽 공간이 부족하면 아래쪽에 표시
                if (top < $(window).scrollTop() + 5) {

                        top = offset.top + $target.outerHeight() + 8;
                }

                $tooltip.css({
                        left: left + 'px',
                        top: top + 'px'
                });

                // ==================================================
                // 툴팁 닫기
                // ==================================================
                function closeTooltip() {

                        clearTimeout(tooltipTimer);

                        $tooltip.remove();

                        $(window).off('.ccReportTooltip');
                        $(document).off('.ccReportTooltip');
                }

                // ==================================================
                // 5초 후 자동 닫기
                // ==================================================
                var tooltipTimer = setTimeout(function() {

                        closeTooltip();

                }, 5000);


                // ==================================================
                // 화면 스크롤 시 닫기
                // ==================================================
                $(window).on('scroll.ccReportTooltip', function() {

                        closeTooltip();
                });

                // ==================================================
                // 툴팁 바깥 클릭 시 닫기
                // ==================================================
                $(document).on('click.ccReportTooltip', function(e) {

                        // 툴팁 내부 클릭이면 유지
                        if ($(e.target).closest('.cc-report-tooltip').length) {
                                return;
                        }

                        // Unpublished 클릭 대상이면 유지
                        if ($(e.target).closest('.cc-reply-unpublished').length) {
                                return;
                        }

                        closeTooltip();
                });
        }



        // ==================================================
        // 툴팁 자동 닫기
        // 1. 툴팁 바깥 클릭 시 닫기
        // 2. 스크롤 발생 시 닫기
        // ==================================================
        function bindTooltipAutoClose($tooltip, $close, $target) {

                var closed = false;

                function closeTooltip() {

                        if (closed) {
                                return;
                        }

                        closed = true;

                        $close.trigger('click');

                        $(document).off('.ccTooltipAuto');
                        $(window).off('.ccTooltipAuto');

                        document.removeEventListener(
                                'scroll',
                                onScroll,
                                true
                        );
                }

                // ==================================================
                // 툴팁 바깥 클릭 시 닫기
                // ==================================================
                $(document)
                        .off('mousedown.ccTooltipAuto')
                        .on('mousedown.ccTooltipAuto', function(e) {

                                // 툴팁 내부 클릭이면 유지
                                if (
                                        $(e.target).closest($tooltip).length
                                ) {
                                        return;
                                }

                                closeTooltip();
                        });

                // ==================================================
                // 모든 영역의 스크롤 감지
                // ==================================================
                function onScroll() {

                        closeTooltip();
                }

                document.addEventListener(
                        'scroll',
                        onScroll,
                        true
                );

                $(window).on(
                        'scroll.ccTooltipAuto',
                        onScroll
                );

                // ==================================================
                // X 버튼 직접 클릭 시 이벤트 정리
                // ==================================================
                $close.off('click.ccTooltipAutoCleanup')
                        .on('click.ccTooltipAutoCleanup', function() {

                                if (closed) {
                                        return;
                                }

                                closed = true;

                                $(document).off('.ccTooltipAuto');
                                $(window).off('.ccTooltipAuto');

                                document.removeEventListener(
                                        'scroll',
                                        onScroll,
                                        true
                                );
                        });
        }


        // ==================================================
        // 댓글 삭제 확인 툴팁
        // ==================================================
        function showDeleteConfirmTooltip($target, replyNo, message) {

                $('.cc-delete-tooltip').remove();

                var $tooltip = $('<div></div>')
                        .addClass('cc-author-tooltip cc-delete-tooltip')
                        .css({
                                position: 'absolute',
                                zIndex: 999999,
                                display: 'block',
                                minWidth: '190px',
                                padding: '12px 30px 12px 12px',
                                background: '#fff',
                                border: '1px solid #ddd',
                                borderRadius: '8px',
                                boxShadow: '0 3px 12px rgba(0,0,0,0.15)'
                        });

                // 우측 상단 닫기 버튼
                var $close = $('<span></span>')
                        .addClass('cc-tooltip-close')
                        .text('×')
                        .css({
                                position: 'absolute',
                                top: '3px',
                                right: '8px',
                                cursor: 'pointer',
                                fontSize: '18px',
                                fontWeight: 'bold',
                                lineHeight: '18px',
                                color: '#666'
                        });

                $tooltip.append($close);

                // X 클릭 시 닫기
                $close.on('click', function(e) {

                        e.preventDefault();
                        e.stopPropagation();

                        $tooltip.remove();

                        return false;
                });

                // 자동 닫기 적용
                bindTooltipAutoClose($tooltip, $close);

                // 안내 문구
                $tooltip.append(
                        $('<div></div>')
                                .css({
                                        fontSize: '13px',
                                        marginBottom: '12px',
                                        color: '#333'
                                })
                                .text(message || 'Delete this message?')
                );

                // 버튼 영역
                var $buttons = $('<div></div>').css({
                        display: 'flex',
                        justifyContent: 'flex-end',
                        alignItems: 'center',
                        gap: '8px'
                });

                // No 버튼
                $buttons.append(
                        $('<button type="button"></button>')
                                .addClass('cc-delete-confirm-no')
                                .css({
                                        border: '1px solid #ddd',
                                        background: '#fff',
                                        color: '#555',
                                        borderRadius: '5px',
                                        padding: '4px 12px',
                                        fontSize: '12px'
                                })
                                .text('No')
                );

                // Yes 버튼
                $buttons.append(
                        $('<button type="button"></button>')
                                .addClass('cc-delete-confirm-yes')
                                .css({
                                        border: '1px solid #dc3545',
                                        background: '#dc3545',
                                        color: '#fff',
                                        borderRadius: '5px',
                                        padding: '4px 12px',
                                        fontSize: '12px'
                                })
                                .text('Yes')
                );

                $tooltip.append($buttons);

                $('body').append($tooltip);

                // Report 툴팁과 동일한 위치 계산 함수 사용
                positionReportTooltip($tooltip, $target);

                // ==================================================
                // No 클릭
                // ==================================================
                $tooltip.find('.cc-delete-confirm-no')
                        .off('click.ccDeleteConfirm')
                        .on('click.ccDeleteConfirm', function(e) {

                                e.preventDefault();
                                e.stopPropagation();

                                $tooltip.remove();

                                return false;
                        });

                // ==================================================
                // Yes 클릭
                // ==================================================
                $tooltip.find('.cc-delete-confirm-yes')
                        .off('click.ccDeleteConfirm')
                        .on('click.ccDeleteConfirm', function(e) {

                                e.preventDefault();
                                e.stopPropagation();

                                $tooltip.remove();

                                // 확인 완료 상태 설정
                                $target.data('deleteConfirmed', true);

                                // 기존 삭제 이벤트 다시 실행
                                $target.trigger('click');

                                return false;
                        });
        }



        // ==================================================
        // 신고 확인 툴팁
        // ==================================================
        function showReportConfirmTooltip($target, replyNo) {

                $('.cc-report-tooltip').remove();

                var $tooltip = $('<div></div>')
                        .addClass('cc-author-tooltip cc-report-tooltip')
                        .css({
                                position: 'absolute',
                                zIndex: 999999,
                                display: 'block',
                                minWidth: '190px',
                                maxWidth: 'min(260px, calc(100vw - 24px))',
                                boxSizing: 'border-box',
                                padding: '12px 30px 12px 12px',
                                background: '#fff',
                                color: '#333',
                                border: '1px solid rgba(0,0,0,.12)',
                                borderRadius: '8px',
                                boxShadow: '0 3px 14px rgba(0,0,0,.16)'
                        });

                $tooltip.append(
                        $('<div></div>')
                                .css({
                                        fontSize: '13px',
                                        marginBottom: '10px'
                                })
                                .text('Report this message?')
                );

                var $buttons = $('<div></div>').css({
                        display: 'flex',
                        justifyContent: 'flex-end',
                        gap: '8px'
                });

                var $no = $('<button type="button"></button>')
                        .text('No')
                        .css({
                                border: '1px solid #ced4da',
                                background: '#fff',
                                color: '#333',
                                borderRadius: '5px',
                                padding: '4px 12px',
                                fontSize: '12px'
                        });

                var $yes = $('<button type="button"></button>')
                        .text('Yes')
                        .css({
                                border: '1px solid #dc3545',
                                background: '#dc3545',
                                color: '#fff',
                                borderRadius: '5px',
                                padding: '4px 12px',
                                fontSize: '12px'
                        });

                var $close = $('<span></span>')
                        .addClass('cc-tooltip-close')
                        .text('×')
                        .css({
                                position: 'absolute',
                                top: '3px',
                                right: '8px',
                                cursor: 'pointer',
                                fontSize: '18px',
                                fontWeight: 'bold',
                                lineHeight: '18px',
                                color: '#666'
                        });

                // X 클릭 시 툴팁 닫기
                $close.on('click', function(e) {

                        e.preventDefault();
                        e.stopPropagation();

                        $tooltip.remove();

                        return false;
                });

                // 마우스 이탈 및 스크롤 자동 닫기
                bindTooltipAutoClose($tooltip, $close);

                $buttons.append($no).append($yes);

                $tooltip.append($buttons).append($close);

                $('body').append($tooltip);

                positionReportTooltip($tooltip, $target);

                function closeTooltip() {
                        $tooltip.remove();
                }

                $no.on('click', function(e) {

                        e.preventDefault();
                        e.stopPropagation();

                        closeTooltip();
                });

                $close.on('click', function(e) {

                        e.preventDefault();
                        e.stopPropagation();

                        closeTooltip();
                });

                // ==================================================
                // 신고하기
                // ==================================================
                $yes.on('click', function(e) {

                        e.preventDefault();
                        e.stopPropagation();

                        if ($yes.prop('disabled')) {
                                return;
                        }

                        $yes.prop('disabled', true).text('Sending...');

                        $.ajax({

                                url: 'https://co.cc/reply/short_call_code_reply_report_save_ajax.php',

                                type: 'POST',

                                dataType: 'json',

                                xhrFields: {
                                        withCredentials: true
                                },

                                data: {
                                        short_code_no: shortCodeNo,
                                        short_code: shortCode,
                                        reply_no: replyNo
                                },

                                success: function(res) {

                                        if (res && parseInt(res.proc, 10) == 1) {

                                                var targetObj = null;

                                                // ==================================================
                                                // 원댓글 확인
                                                // ==================================================
                                                if (
                                                        current
                                                        && parseInt(current.id, 10) == replyNo
                                                ) {

                                                        targetObj = current;

                                                } else if (current) {

                                                        // ==================================================
                                                        // 2차 댓글 확인
                                                        // ==================================================
                                                        targetObj = findRep(current, replyNo);
                                                }

                                                // 신고 완료 상태 저장
                                                if (targetObj) {
                                                        targetObj.my_report = 1;
                                                }

                                                closeTooltip();

                                                // ==================================================
                                                // 원댓글 신고 완료
                                                // ==================================================
                                                if (targetObj === current && targetObj) {

                                                        renderViewVote();

                                                        showReportMessageTooltip(
                                                                $('#ccViewActs'),
                                                                res.mssg || 'Your report has been submitted.'
                                                        );

                                                // ==================================================
                                                // 2차 댓글 신고 완료
                                                // ==================================================
                                                } else if (targetObj) {

                                                        renderReplies(current);

                                                        showReportMessageTooltip(
                                                                $('#ccRepList .cc-rep[data-rid="' + replyNo + '"]'),
                                                                res.mssg || 'Your report has been submitted.'
                                                        );

                                                } else {

                                                        showReportMessageTooltip(
                                                                $target,
                                                                res.mssg || 'Your report has been submitted.'
                                                        );
                                                }

                                        } else {

                                                closeTooltip();

                                                showReportMessageTooltip(
                                                        $target,
                                                        res && res.mssg
                                                                ? res.mssg
                                                                : 'Failed to submit report.'
                                                );
                                        }
                                },

                                error: function(xhr, status, error) {

                                        ccLog('Report AJAX error:', error);
                                        ccLog(xhr.responseText);

                                        closeTooltip();

                                        showReportMessageTooltip(
                                                $target,
                                                'Failed to submit report. Please try again.'
                                        );
                                }
                        });
                });
        }




        // ==================================================
        // 원댓글 / 2차 댓글 신고 클릭 이벤트
        // ==================================================
        $(document)
                .off('click.ccReplyReport', '.cc-reply-report')
                .on('click.ccReplyReport', '.cc-reply-report', function(e) {

                        e.preventDefault();
                        e.stopPropagation();
                        e.stopImmediatePropagation();

                        var $reportBtn = $(this);

                        var replyNo = parseInt(
                                $reportBtn.attr('data-rid'),
                                10
                        );

                        if (isNaN(replyNo) || replyNo <= 0) {
                                return false;
                        }

                        showReportConfirmTooltip($reportBtn, replyNo);

                        return false;
                });


        // ==================================================
        // Report 클릭
        // ==================================================
        $('#ccViewActs')
                .off('click.ccReplyReport', '.cc-reply-report')
                .on('click.ccReplyReport', '.cc-reply-report', function(e) {

                        e.preventDefault();
                        e.stopPropagation();

                        var $target = $(this);
                        var replyNo = parseInt($target.attr('data-rid'), 10);

                        if (replyNo <= 0) {
                                return;
                        }

                        showReportConfirmTooltip($target, replyNo);
                });







                // ==================================================
                // 대댓글 목록 그리기
                // ==================================================
                function renderReplies(m, appendMode) {

                        appendMode = (appendMode === true);

                        // 대댓글 배열 확인
                        var replies = $.isArray(m.replies) ? m.replies : [];

                        ccLog('========== renderReplies 데이터 확인 ==========');
                        ccLog('parent id:', m.id);
                        ccLog('replies:', replies);
                        ccLog('replies 개수:', replies.length);
                        ccLog('ccReplyTotalCount:', ccReplyTotalCount);
                        ccLog('ccReplyHasMore:', ccReplyHasMore);
                        ccLog('appendMode:', appendMode);
                        ccLog('==============================================');

                        var $r = $('#ccRepList');

                        // ==================================================
                        // 최초 출력이면 목록 초기화
                        // ==================================================

                        if (!appendMode) {

                                $r.empty();

                                // 실제 DOM에 출력된 대댓글 개수 초기화
                                ccReplyRenderedCount = 0;

                                ccReplyMoreAutoClick = false;

                        } else {

                                $('#ccRepAutoLoading').remove();
                        }


                        // ==================================================
                        // 대댓글 목록 헤더
                        // ==================================================

                        var $head = $('#ccRepHead').empty();

                        $head.css({
                                display: 'flex',
                                alignItems: 'center',
                                justifyContent: 'space-between'
                        });

                        $head.append(
                                $('<span></span>').text(
                                        ccReplyTotalCount > 0
                                                ? 'Replies (' + ccReplyTotalCount + ')'
                                                : 'Replies'
                                )
                        );

                        // ==================================================
                        // 대댓글이 2개 이상일 때 정렬 메뉴 표시
                        // ==================================================

                        if (ccReplyTotalCount >= 2) {

                                var $sort = $('<div class="small cc-sort-wrap"></div>');

                                $sort.append(
                                        $('<a></a>')
                                                .attr('href', '#')
                                                .attr('id', 'ccRepTop')
                                                .attr('data-parent-no', m.id)
                                                .addClass('cc-sort-link')
                                                .toggleClass('active', currentReplySort != 'newest')
                                                .text('Top')
                                );

                                $sort.append(
                                        $('<span></span>')
                                                .addClass('text-secondary mx-1')
                                                .text('·')
                                );

                                $sort.append(
                                        $('<a></a>')
                                                .attr('href', '#')
                                                .attr('id', 'ccRepNewest')
                                                .attr('data-parent-no', m.id)
                                                .addClass('cc-sort-link')
                                                .toggleClass('active', currentReplySort == 'newest')
                                                .text('Newest')
                                );

                                $head.append($sort);
                        }

                        // ==================================================
                        // 대댓글이 없는 경우
                        // ==================================================

                        if (!ccReplyTotalCount) {

                                $r.append(
                                        '<div class="cc-rep-empty">No replies yet. Be the first!</div>'
                                );

                                return;
                        }


                        // ==================================================
                        // 이번에 출력할 대댓글 범위
                        // parent.replies는 기존 댓글 + 신규 댓글 누적 배열
                        // 이미 출력된 댓글은 제외
                        // ==================================================

                        var replyStart = appendMode ? ccReplyRenderedCount : 0;

                        var replyData = replies.slice(replyStart);

                        ccLog('========== 대댓글 화면 출력 ==========');
                        ccLog('appendMode:', appendMode);
                        ccLog('기존 DOM 출력 개수:', ccReplyRenderedCount);
                        ccLog('서버 수신 개수:', replies.length);
                        ccLog('이번 출력 시작 위치:', replyStart);
                        ccLog('이번 출력 개수:', replyData.length);
                        ccLog('======================================');


                        ccLog('부모 댓글 photo_count:', current.photo_count);
                        ccLog('부모 댓글 photos.length:', current.photos.length);
                        // ==================================================
                        // 대댓글 출력
                        // ==================================================

                        $.each(replyData, function(_, rp) {

                                var $av = $('<div class="cc-rep-av"></div>');

                                if (rp.owner) {

                                        $av.append(
                                                $('<img alt="">').attr('src', ccOwner.img)
                                        );

                                } else {

                                        if (rp.from === 'Anonymous') {

                                                $av.text('?');

                                        } else {

                                                if (rp.from_img) {

                                                        $av.append(
                                                                $('<img alt="">').attr('src', rp.from_img)
                                                        );

                                                } else {

                                                        var from_strip = strip_tags(rp.from).trim();

                                                        $av.text(
                                                                from_strip.charAt(0).toUpperCase()
                                                        );
                                                }
                                        }
                                }

                                var $top = $('<div class="cc-rep-top"></div>')
                                        .append(
                                                $('<span class="cc-rep-name"></span>').html(rp.from)
                                        );

                                if (rp.owner) {

                                        $top.append(
                                                '<span class="cc-rep-owner">Owner</span>'
                                        );
                                }

                                // ==================================================
                                // 2차 댓글 작성 시간 표시
                                // ==================================================

                                var $time = $('<span></span>');

                                if (rp.reply_stat == '') {

                                        $time
                                                .addClass('cc-reply-publishing')
                                                .text('· Publishing…');

                                } else if (rp.reply_stat != 'normal') {

                                        $time
                                                .addClass('cc-reply-unpublished')
                                                .attr('role', 'button')
                                                .attr('tabindex', '0')
                                                .css({
                                                        cursor: 'pointer'
                                                })
                                                .text('· Unpublished');

                                        // ==================================================
                                        // Unpublished 클릭
                                        // ==================================================

                                        $time.on('click', function(e) {

                                                e.preventDefault();
                                                e.stopPropagation();
                                                e.stopImmediatePropagation();

                                                showReportMessageTooltip(
                                                        $(this),
                                                        'This post may make others feel uncomfortable, so it hasn’t been published yet.'
                                                );

                                                return false;
                                        });

                                } else {

                                        $time.text('· ' + rp.time);
                                }

                                $top.append($time);

                                // ==================================================
                                // 투표 영역
                                // ==================================================

                                var $vote = $(voteEl(rp, true));

                                // ==================================================
                                // 투표 + Photo / Delete / Report 버튼 영역
                                // ==================================================

                                var $actions = $('<div></div>').css({
                                        display: 'flex',
                                        alignItems: 'center',
                                        width: '100%'
                                });

                                $actions.append($vote);

                                // ==================================================
                                // 권한 확인
                                // ==================================================

                                // 댓글 작성자 또는 Short Code 소유자만 Delete 가능
                                var canDelete = (
                                        parseInt(rp.can_delete, 10) == 1
                                        || rp.can_delete === true
                                );

                                // 실제 댓글 작성자만 Photo 가능
                                var canPhoto = (
                                        parseInt(rp.can_photo, 10) == 1
                                        || rp.can_photo === true
                                );

                                // 신고 가능 여부
                                var canReport = (
                                        parseInt(rp.can_report, 10) == 1
                                        || rp.can_report === true
                                );

                                // Published 상태의 실제 작성자 댓글만 Photo 표시
                                var hasPhoto = (
                                        canPhoto
                                        && rp.reply_stat == 'normal'
                                );

                                // ==================================================
                                // Photo 버튼
                                // ==================================================

                                if (hasPhoto) {

                                        $actions.append(
                                                makeReplyPhotoButton(rp).css({
                                                        marginLeft: 'auto',
                                                        marginRight: '12px',
                                                        whiteSpace: 'nowrap',
                                                        flexShrink: 0
                                                })
                                        );
                                }

                                // ==================================================
                                // Delete 버튼
                                // ==================================================

                                if (canDelete) {

                                        $actions.append(
                                                $('<a></a>')
                                                        .attr('href', '#')
                                                        .addClass('cc-reply-delete text-danger small')
                                                        .attr('data-rid', rp.id)
                                                        .css({
                                                                marginLeft: hasPhoto ? '0' : 'auto',
                                                                whiteSpace: 'nowrap',
                                                                flexShrink: 0,
                                                                fontWeight: 'normal',
                                                                fontSize: '85%'
                                                        })
                                                        .text('Delete')
                                        );

                                } else if (canReport && !isReplyReported(rp)) {

                                        // ==================================================
                                        // Report 버튼
                                        // ==================================================

                                        var $reportAction = makeReplyReportAction(rp);

                                        if ($reportAction) {
                                                $actions.append($reportAction);
                                        }
                                }

                                // ==================================================
                                // 댓글 본문
                                // ==================================================

                                var $body = $('<div class="cc-rep-body"></div>');

                                $body.append($top);

                                // 댓글 텍스트
                                $body.append(
                                        $('<div class="cc-rep-text"></div>').text(rp.text)
                                );

                                // ==================================================
                                // 첨부 이미지
                                // 삭제 권한이 있으면 사진 우측 상단에 × 표시
                                // 부모 댓글과 동일한 공통 함수 사용
                                // ==================================================

                                var photoCount = parseInt(rp.photo_count, 10) || 0;
                                var photos = $.isArray(rp.photos) ? rp.photos : [];

                                ccLog('========== 대댓글 사진 확인 ==========');
                                ccLog('reply id:', rp.id);
                                ccLog('photo_count:', rp.photo_count);
                                ccLog('photos:', rp.photos);
                                ccLog('can_delete:', rp.can_delete);
                                ccLog('======================================');

                                if (photoCount > 0 && photos.length > 0) {

                                        var $photoList = makeReplyPhotoList(rp, false);

                                        if ($photoList.children().length > 0) {
                                                $body.append($photoList);
                                        }
                                }

                                // ==================================================
                                // 투표 / Photo / Delete / Report 버튼
                                // ==================================================

                                $body.append($actions);

                                // ==================================================
                                // 대댓글 카드 출력
                                // ==================================================

                                $r.append(
                                        $('<div class="cc-rep"></div>')
                                                .attr('data-rid', rp.id)
                                                .append($av)
                                                .append($body)
                                );

                        });

                        ccLog('렌더링 후 DOM 개수:', $('#ccRepList .cc-rep').length);

                        // ==================================================
                        // 현재까지 실제 출력된 대댓글 개수 갱신
                        // ==================================================

                        ccReplyRenderedCount += replyData.length;

                        // ==================================================
                        // 추가 댓글이 남아 있으면 Loading 영역 생성
                        // ==================================================

                        if (ccReplyHasMore) {

                                $r.append(
                                        $('<div></div>')
                                                .attr('id', 'ccRepAutoLoading')
                                                .addClass('text-center py-3')
                                                .html(
                                                        '<span class="spinner-border spinner-border-sm text-secondary" role="status"></span>' +
                                                        '<span class="small text-secondary ms-2">Loading...</span>'
                                                )
                                                .hide()
                                );
                        }

                        ccLog('========== 대댓글 출력 완료 ==========');
                        ccLog('현재 DOM 출력 개수:', ccReplyRenderedCount);
                        ccLog('추가 데이터 여부:', ccReplyHasMore);
                        ccLog('======================================');
                }







        // ==================================================
        // 2차 댓글 하단 감지
        // 하단 도달 시 서버에서 5개 추가 조회
        // ==================================================
        function ccReplyCheckBottom() {

                if (!current) {
                        return;
                }

                if (!ccReplyHasMore) {
                        return;
                }

                if (ccReplyLoading || ccReplyMoreAutoClick) {
                        return;
                }

                var $scroll = $('#ccViewScroll');

                if (!$scroll.length) {
                        return;
                }

                var scrollTop = $scroll.scrollTop();
                var scrollHeight = $scroll[0].scrollHeight;
                var clientHeight = $scroll.innerHeight();

                var remain = scrollHeight - scrollTop - clientHeight;

                ccLog('========== 2차 댓글 하단 감지 ==========');
                ccLog('scrollTop:', scrollTop);
                ccLog('scrollHeight:', scrollHeight);
                ccLog('clientHeight:', clientHeight);
                ccLog('하단 남은 거리:', remain);
                ccLog('hasMore:', ccReplyHasMore);
                ccLog('nextOffset:', ccReplyNextOffset);
                ccLog('========================================');

                // 하단 100px 이내 도달
                if (remain <= 100) {

                        ccLog('2차 댓글 추가 AJAX 실행');

                        $('#ccRepAutoLoading').show();

                        loadMsgDataAfterReply(current.id, true);
                }
        }




        // ==================================================
        // 상세 팝업 스크롤 이벤트
        // ==================================================


        // ==================================================
        // 2차 댓글 자동 스크롤 이벤트
        // ==================================================
        $('#ccViewScroll')
                .off('scroll.ccReplyAutoMore')
                .on('scroll.ccReplyAutoMore', function() {

                        ccReplyCheckBottom();

                });



        // ==================================================
        // 2차 댓글 Top
        // ==================================================

        $(document)
                .off('click.ccRepTop', '#ccRepTop')
                .on('click.ccRepTop', '#ccRepTop', function(e) {

                        e.preventDefault();
                        e.stopPropagation();

                        var parentNo = parseInt(
                                $(this).attr('data-parent-no'),
                                10
                        );

                        if (!parentNo || isNaN(parentNo)) {

                                ccLog('잘못된 parentNo');

                                return false;
                        }

                        currentReplySort = '';

                        ccLog('2차 정렬 요청:', {
                                parentNo: parentNo,
                                reply_sort: currentReplySort
                        });

                        loadMsgDataAfterReply(parentNo);

                        return false;
                });


        // ==================================================
        // 2차 댓글 Newest 정렬
        // 1차 댓글 정렬은 유지
        // ==================================================
        $(document)
                .off('click.ccRepNewest', '#ccRepNewest')
                .on('click.ccRepNewest', '#ccRepNewest', function(e) {

                        e.preventDefault();
                        e.stopPropagation();

                        var parentNo = parseInt(
                                $(this).attr('data-parent-no'),
                                10
                        );

                        if (!parentNo || isNaN(parentNo)) {

                                ccLog('잘못된 parentNo');

                                return false;
                        }

                        // 기존 1차 댓글 정렬값 보존
                        var keepRootSort = currentRootSort;

                        // 2차 댓글만 Newest 변경
                        currentReplySort = 'newest';

                        ccLog('2차 정렬 요청:', {
                                parentNo: parentNo,
                                root_sort: keepRootSort,
                                reply_sort: currentReplySort
                        });

                        loadMsgDataAfterReply(parentNo);

                        // 1차 댓글 정렬값 유지
                        currentRootSort = keepRootSort;

                        return false;
                });


        // ==================================================
        // 상세 팝업의 댓글 투표
        // ==================================================
        $('#ccViewActs').on('click', '.cc-vbtn', function(e) {

                e.stopPropagation();

                if (!current) {
                        return;
                }

                var dir = parseInt($(this).attr('data-dir'), 10);

                $(this).prop('disabled', true);

                applyVote(current, dir);
        });


        // ==================================================
        // 상세 팝업의 대댓글 투표
        // ==================================================
        $('#ccRepList').on('click', '.cc-vbtn', function(e) {

                e.stopPropagation();

                if (!current) {
                        return;
                }

                var $btn = $(this);

                var rp = findRep(
                        current,
                        parseInt($btn.closest('.cc-rep').attr('data-rid'), 10)
                );

                if (!rp) {
                        return;
                }

                var dir = parseInt($btn.attr('data-dir'), 10);

                $btn.prop('disabled', true);

                applyVote(rp, dir);
        });



        // ==================================================
        // 상세 팝업 열기
        // ==================================================
        function openView(id) {

                current = findMsg(id);

                if (!current) {
                        return;
                }

                // ==================================================
                // 작성자 아바타 + 이름
                // ==================================================
                var fromText = $('<div></div>').html(current.from).text().trim();
                var firstChar = 'A';

                if (fromText.toLowerCase() == 'anonymous') {
                        firstChar = '?';
                } else if (fromText) {
                        firstChar = fromText.substring(0, 1).toUpperCase();
                }

                var $av = $('<div class="cc-rep-av"></div>');

                if (current.from_img) {
                        $av.append(
                                $('<img>').attr('src', current.from_img)
                        );
                } else {
                        $av.text(firstChar);
                }

                $('#ccViewFrom').empty().append(
                        $('<span class="d-inline-flex align-items-center gap-2"></span>')
                                .append($av)
                                .append($('<span></span>').html(current.from))
                );


                
                // ==================================================
                // 상세창 부모 댓글 작성 시간 표시
                // ==================================================
                var $viewTime = $('#ccViewTime').empty();

                if (current.reply_stat == '') {

                        $viewTime
                                .addClass('cc-reply-publishing')
                                .text('Publishing…');

                } else if (current.reply_stat != 'normal') {

                        $viewTime
                                .removeClass('cc-reply-publishing')
                                .addClass('cc-reply-unpublished')
                                .attr('role', 'button')
                                .attr('tabindex', '0')
                                .css('cursor', 'pointer')
                                .text('Unpublished');

                        // ==================================================
                        // 부모 댓글 Unpublished 클릭 이벤트
                        // ==================================================
                        $viewTime
                                .off('click.ccViewUnpublished')
                                .on('click.ccViewUnpublished', function(e) {

                                        e.preventDefault();
                                        e.stopPropagation();
                                        e.stopImmediatePropagation();

                                        showReportMessageTooltip(
                                                $(this),
                                                'This post may make others feel uncomfortable, so it hasn’t been published yet.'
                                        );

                                        return false;
                                });

                } else {

                        $viewTime
                                .removeClass('cc-reply-publishing cc-reply-unpublished')
                                .removeAttr('role tabindex')
                                .css('cursor', '')
                                .text(current.time);
                }



                // ==================================================
                // 부모 댓글 본문
                // ==================================================

                $('#ccViewText').text(current.text);

                // ==================================================
                // 부모 댓글 첨부 이미지
                // 삭제 권한이 있으면 × 버튼 표시
                // ==================================================

                $('#ccViewPhotos').remove();

                var photoCount = parseInt(current.photo_count, 10) || 0;
                var photos = $.isArray(current.photos) ? current.photos : [];

                ccLog('========== 부모 댓글 사진 확인 ==========');
                ccLog('reply id:', current.id);
                ccLog('photo_count:', current.photo_count);
                ccLog('photos:', current.photos);
                ccLog('photos 배열 여부:', $.isArray(current.photos));
                ccLog('can_delete:', current.can_delete);
                ccLog('======================================');

                if (photoCount > 0 && photos.length > 0) {

                        var $photoList = makeReplyPhotoList(current, true);

                        if ($photoList.children().length > 0) {

                                $photoList.attr('id', 'ccViewPhotos');

                                $('#ccViewText').after($photoList);
                        }
                }

                renderViewVote();
                renderReplies(current);



                // 서버에서 해당 원댓글의 2차 댓글 조회
                loadMsgDataAfterReply(id);

                $('#ccRepText').val('').css('height', '');
                $('#ccRepSend').prop('disabled', true);
                $('#ccRepAnon').prop('checked', false);

                $('body').addClass('cc-msg-open');

                $('#ccViewOverlay').show();
                $('#ccViewPopup').addClass('cc-show');

                $('#ccMsgName').val(cheerAs);

                $('#ccViewScroll').scrollTop(0);



        }


        // ==================================================
        // 상세 팝업 닫기
        // ==================================================
        function closeView() {

                $('#ccViewOverlay').hide();
                $('#ccViewPopup').removeClass('cc-show');

                $('body').removeClass('cc-msg-open');

                $('#ccRepText').trigger('blur');
        }




        // ==================================================
        // 댓글 사진 출력
        // 삭제 권한이 있는 경우 × 버튼 표시
        // 댓글 첨부 사진 목록
        // ==================================================
        function makeReplyPhotoList(m, isRoot) {

                var $list = $('<div class="cc-rep-photo-list"></div>');

                var photos = $.isArray(m.photos) ? m.photos : [];

                var canDelete = (
                        parseInt(m.can_delete, 10) == 1
                        || m.can_delete === true
                );

                ccLog('========== 사진 목록 렌더링 ==========');
                ccLog('reply id:', m.id);
                ccLog('photo_count:', m.photo_count);
                ccLog('photos.length:', photos.length);
                ccLog('photos:', photos);

                $.each(photos, function(i, photo) {

                        ccLog('사진 확인:', i);
                        ccLog('photo_no:', photo.photo_no);
                        ccLog('photo_src:', photo.photo_src);

                        if (
                                !photo.photo_no
                                || !photo.photo_src
                        ) {
                                ccLog('사진 제외:', i);
                                return;
                        }

                        var $item = $('<div class="cc-rep-photo-item"></div>')
                                .attr('data-photo-no', photo.photo_no)
                                .attr('data-reply-no', m.id)
                                .attr('data-root', isRoot ? 'y' : 'n');

                        $item.css({
                                position: 'relative',
                                display: 'inline-block'
                        });

                        // ==================================================
                        // 이미지 생성
                        // 실제 이미지 크기는 load 이벤트에서 계산
                        // ==================================================


                        var $img = $('<img alt="">')
                                .attr('src', photo.photo_src)
                                .css({
                                        display: 'block',
                                        width: 'auto',
                                        height: 'auto',
                                        maxWidth: 'none',
                                        maxHeight: 'none',
                                        objectFit: 'contain',
                                        borderRadius: '8px'
                                });



                        $img.on('load', function() {

                                var imgWidth = this.naturalWidth;
                                var imgHeight = this.naturalHeight;

                                if (
                                        imgWidth <= 0
                                        || imgHeight <= 0
                                ) {
                                        return;
                                }

                                // ==================================================
                                // 이미지가 표시될 수 있는 실제 부모 너비
                                // 1차 댓글 / 2차 댓글 각각의 영역 기준
                                // ==================================================

                                var availableWidth = $item.parent().width();

                                if (!availableWidth || availableWidth <= 0) {
                                        availableWidth = 380;
                                }

                                // 좌우 여백
                                availableWidth = Math.max(1, availableWidth - 4);

                                // ==================================================
                                // 500x500 이하 이미지는 짧은 변을 500 기준으로 확대
                                // ==================================================

                                var baseWidth = imgWidth;
                                var baseHeight = imgHeight;

                                if (
                                        imgWidth <= 500
                                        && imgHeight <= 500
                                ) {

                                        if (imgWidth <= imgHeight) {

                                                baseWidth = 500;
                                                baseHeight = Math.round(
                                                        imgHeight * 500 / imgWidth
                                                );

                                        } else {

                                                baseHeight = 500;
                                                baseWidth = Math.round(
                                                        imgWidth * 500 / imgHeight
                                                );

                                        }
                                }

                                // ==================================================
                                // 실제 댓글 영역보다 크면 비율을 유지하며 축소
                                // ==================================================

                                var scale = Math.min(
                                        1,
                                        availableWidth / baseWidth
                                );

                                var displayWidth = Math.round(baseWidth * scale);
                                var displayHeight = Math.round(baseHeight * scale);

                                $(this).css({
                                        display: 'block',
                                        width: displayWidth + 'px',
                                        height: displayHeight + 'px',
                                        maxWidth: '100%',
                                        maxHeight: 'none',
                                        objectFit: 'contain'
                                });

                                ccLog('사진 크기 계산:', photo.photo_no);
                                ccLog('원본 크기:', imgWidth, imgHeight);
                                ccLog('댓글 영역 너비:', availableWidth);
                                ccLog('최종 표시 크기:', displayWidth, displayHeight);
                        });


                        $img.on('error', function() {

                                ccLog(
                                        '사진 로드 실패:',
                                        photo.photo_no,
                                        photo.photo_src
                                );

                        });

                        $item.append($img);

                        // ==================================================
                        // 삭제 권한이 있는 경우 × 표시
                        // ==================================================

                        if (canDelete) {

                                var $delete = $('<button type="button"></button>')
                                        .addClass('cc-photo-delete')
                                        .attr('data-photo-no', photo.photo_no)
                                        .attr('title', '삭제하기')
                                        .attr('aria-label', '삭제하기')
                                        .text('×');


                                        $delete.css({
                                                position: 'absolute',
                                                top: '5px',
                                                right: '5px',
                                                width: '25px',
                                                height: '25px',
                                                padding: '0',
                                                border: '0',
                                                borderRadius: '50%',
                                                background: 'rgba(0,0,0,0.7)',
                                                color: '#fff',
                                                fontSize: '20px',
                                                lineHeight: '23px',
                                                textAlign: 'center',
                                                cursor: 'pointer',
                                                zIndex: 5
                                        });

                                $item.append($delete);
                        }

                        // 사진과 사진 사이에 Bootstrap의 m-2 정도 간격(8px)을 주면 됩니다.

                        $item.css({
                                position: 'relative',
                                display: 'inline-block',
                                margin: '0 8px 8px 0',
                                verticalAlign: 'top',
                                maxWidth: '100%'
                        });


                        $list.append($item);
                });

                ccLog('전달된 사진 개수:', photos.length);
                ccLog('실제 생성된 사진 DOM 개수:', $list.children().length);
                ccLog('======================================');

                return $list;
        }


        // ==================================================
        // 부모 댓글 사진 목록 갱신
        // ==================================================
        function refreshRootPhotos(current) {

                if (!current) return;

                $('#ccViewPhotos').remove();

                var photoCount = parseInt(current.photo_count, 10) || 0;
                var photos = $.isArray(current.photos) ? current.photos : [];

                if (photoCount > 0 && photos.length > 0) {

                        var $photoList = makeReplyPhotoList(current, true);

                        if ($photoList.children().length > 0) {

                                $photoList.attr('id', 'ccViewPhotos');

                                $('#ccViewText').after($photoList);
                        }
                }
        }


        // ==================================================
        // 댓글 카드 클릭
        // ==================================================
        $('#ccMsgList').on('click', '.cc-msg-card', function(e) {

                // 이름 / Report / Delete 클릭이면 상세 팝업 열지 않음
                if ($(e.target).closest(
                        '.cc-author-link, .cc-reply-report, .cc-reply-delete, .cc-reply-photo, .cc-reply-unpublished'
                ).length) {
                        return;
                }

                openView(
                        parseInt($(this).attr('data-id'), 10)
                );
        });


        // ==================================================
        // 댓글 카드 키보드 클릭
        // ==================================================
        $('#ccMsgList').on('keydown', '.cc-msg-card', function(e) {

                if (e.key === 'Enter' && e.target === this) {

                        openView(
                                parseInt($(this).attr('data-id'), 10)
                        );
                }
        });


        $('#ccViewClose, #ccViewOverlay').on('click', closeView);


        // ==================================================
        // 대댓글 입력
        // ==================================================
        $('#ccRepText').on('input', function() {

                this.style.height = 'auto';

                this.style.height = Math.min(this.scrollHeight, 120) + 'px';

                $('#ccRepSend').prop(
                        'disabled',
                        String($(this).val()).trim() === ''
                );
        });



        // ==================================================
        // 2차 댓글 등록
        // ==================================================
        $('#ccRepSend')
                .off('click.ccReplySave')
                .on('click.ccReplySave', function(e) {

                        e.preventDefault();

                        var $btn = $(this);

                        var replyText = String($('#ccRepText').val()).trim();
                        var msgName = String($('#ccMsgName').val()).trim();

                        if (!replyText || !current) {
                                return false;
                        }

                        if (replyText.length > 500) {

                                alert('답변은 500자까지 입력할 수 있습니다.');

                                return false;
                        }

                        if (msgName.length > 30) {

                                alert('이름은 30자까지 입력할 수 있습니다.');

                                return false;
                        }

                        var parentNo = parseInt(current.id, 10);

                        if (parentNo <= 0 || isNaN(parentNo)) {
                                return false;
                        }

                        // 이름이 없으면 익명
                        var anon = msgName == '' ? 'y' : 'n';

                        $btn.prop('disabled', true);

                        $('#ccRepText').prop('disabled', true);
                        $('#ccMsgName').prop('disabled', true);

                        saveMsg(
                                replyText,
                                anon,
                                1,
                                parentNo,
                                msgName,

                                // ==================================
                                // 저장 성공
                                // ==================================
                                function(res) {

                                        $('#ccRepText').val('').css('height', '');
                                        $('#ccMsgName').val('');

                                        $('#ccRepText').prop('disabled', false);
                                        $('#ccMsgName').prop('disabled', false);

                                        $btn.prop('disabled', false);

                                        // 2차 댓글 Newest 정렬
                                        currentReplySort = 'newest';

                                        // 최신순 대댓글 목록 다시 조회
                                        loadMsgDataAfterReply(parentNo);
                                },

                                // ==================================
                                // 저장 실패
                                // ==================================
                                function(res) {

                                        $('#ccRepText').prop('disabled', false);
                                        $('#ccMsgName').prop('disabled', false);

                                        $btn.prop('disabled', false);

                                        var errorMessage = (res && res.mssg)
                                                ? res.mssg
                                                : '답변 저장에 실패했습니다.';

                                        // 기존 툴팁 제거
                                        $('.cc-msg-error-tooltip').remove();

                                        // 툴팁 생성
                                        var $tooltip = $('<div></div>')
                                                .addClass('cc-author-tooltip cc-msg-error-tooltip')
                                                .css({
                                                        position: 'absolute',
                                                        zIndex: 999999,
                                                        paddingRight: '30px'
                                                });

                                        $tooltip.append(
                                                $('<span></span>').text(errorMessage)
                                        );

                                        // 닫기 버튼
                                        var $close = $('<span></span>')
                                                .text('×')
                                                .css({
                                                        position: 'absolute',
                                                        top: '3px',
                                                        right: '8px',
                                                        cursor: 'pointer',
                                                        fontSize: '18px',
                                                        fontWeight: 'bold',
                                                        lineHeight: '18px'
                                                });

                                        $tooltip.append($close);

                                        $('body').append($tooltip);

                                        // 버튼 위치
                                        var offset = $btn.offset();

                                        var tooltipWidth = $tooltip.outerWidth();
                                        var tooltipHeight = $tooltip.outerHeight();

                                        var windowWidth = $(window).width();
                                        var windowHeight = $(window).height();

                                        // 툴팁 오른쪽 끝을 버튼 오른쪽 끝에 맞춤
                                        var tooltipLeft = offset.left
                                                + $btn.outerWidth()
                                                - tooltipWidth;

                                        // 화면 왼쪽 잘림 방지
                                        tooltipLeft = Math.max(
                                                5,
                                                tooltipLeft
                                        );

                                        // 화면 오른쪽 잘림 방지
                                        tooltipLeft = Math.min(
                                                tooltipLeft,
                                                windowWidth + $(window).scrollLeft()
                                                        - tooltipWidth - 5
                                        );

                                        // 기본 위치: 버튼 위쪽 10px
                                        var tooltipTop = offset.top
                                                - tooltipHeight - 10;

                                        // 위쪽 공간이 부족하면 버튼 아래쪽에 표시
                                        if (tooltipTop < $(window).scrollTop() + 5) {

                                                tooltipTop = offset.top
                                                        + $btn.outerHeight() + 10;
                                        }

                                        $tooltip.css({
                                                top: tooltipTop,
                                                left: tooltipLeft
                                        });

                                        // 5초 후 자동 제거
                                        var timer = setTimeout(function() {

                                                $tooltip.remove();

                                        }, 5000);

                                        // X 클릭 시 즉시 제거
                                        $close.on('click', function(e) {

                                                e.preventDefault();
                                                e.stopPropagation();

                                                clearTimeout(timer);
                                                $tooltip.remove();

                                        });
                                }
                        );

                        return false;
                });


                // ==================================================
                // 2차 댓글 서버 페이지 조회
                // 최초 10개, 이후 5개씩 조회
                // ==================================================
                function loadMsgDataAfterReply(parentNo, appendMode) {

                        appendMode = (appendMode === true);


                        // 이전 조회가 진행 중이면 새로고침 요청을 대기시킴
                        if (ccReplyLoading) {

                                if (!appendMode) {

                                        ccReplyReloadPending = true;
                                        ccReplyReloadParentNo = parseInt(parentNo, 10) || 0;

                                        ccLog('2차 댓글 재조회 대기:', ccReplyReloadParentNo);
                                }

                                return;
                        }


                        var parent = findMsg(parentNo);

                        if (!parent) {
                                ccLog('부모 댓글을 찾을 수 없음:', parentNo);
                                return;
                        }

                        // 추가 조회 가능 여부
                        if (appendMode && !ccReplyHasMore) {
                                ccLog('추가 조회할 대댓글이 없습니다.');
                                return;
                        }

                        // 최초 10개 / 추가 5개
                        var requestOffset = appendMode
                                ? ccReplyNextOffset
                                : 0;

                        var requestLimit = appendMode
                                ? ccReplyPageSize
                                : ccReplyVisibleCount;

                        ccReplyLoading = true;
                        ccReplyMoreAutoClick = true;

                        if (!appendMode) {

                                ccReplyNextOffset = 0;
                                ccReplyHasMore = false;
                                ccReplyTotalCount = 0;

                                parent.replies = [];
                        }

                        ccLog('========== 2차 댓글 서버 요청 ==========');
                        ccLog('부모 댓글 번호:', parentNo);
                        ccLog('요청 offset:', requestOffset);
                        ccLog('요청 limit:', requestLimit);
                        ccLog('추가 조회:', appendMode);

                        // 기존 2차 댓글 유지 + 로딩 표시
                        $('#ccRepSortLoading')
                                .stop(true, true)
                                .show();


                        $.ajax({

                                url: listUrl,
                                type: 'POST',
                                dataType: 'json',
                                cache: false,

                                xhrFields: {
                                        withCredentials: true
                                },

                                data: {
                                        short_code_no: shortCodeNo,
                                        short_code: shortCode,

                                        action: 'replies',
                                        parent_no: parentNo,

                                        reply_sort: currentReplySort,

                                        offset: requestOffset,
                                        limit: requestLimit
                                },

                                success: function(res) {

                                        ccLog('========== 2차 댓글 서버 응답 ==========');
                                        ccLog('응답 결과:', res);

                                        if (!res || res.proc != 1) {

                                                ccLog('2차 댓글 조회 실패:', res);

                                                return;
                                        }

                                        var newReplies = res.data || [];

                                        ccLog('이번 조회 개수:', newReplies.length);

                                        // 댓글 데이터 정규화
                                        $.each(newReplies, function(i, rp) {

                                                rp.id = parseInt(rp.id, 10) || 0;
                                                rp.score = parseInt(rp.score, 10) || 0;
                                                rp.myVote = parseInt(rp.myVote, 10) || 0;

                                                rp.owner = (
                                                        rp.owner == 1 ||
                                                        rp.owner === true
                                                );

                                                rp.from = (rp.from == null) ? '' : String(rp.from);
                                                rp.time = rp.time || '';
                                                rp.text = rp.text || '';
                                                // 사진 정보
                                                rp.photo_count = parseInt(rp.photo_count, 10) || 0;
                                                rp.photos = $.isArray(rp.photos) ? rp.photos : [];
                                        });

                                        // 중복 댓글 방지
                                        if (!appendMode) {
                                                parent.replies = [];
                                        }

                                        $.each(newReplies, function(i, rp) {

                                                var exists = false;

                                                $.each(parent.replies, function(j, oldRp) {

                                                        if (parseInt(oldRp.id, 10) == rp.id) {
                                                                exists = true;
                                                                return false;
                                                        }
                                                });

                                                if (!exists) {
                                                        parent.replies.push(rp);
                                                }
                                        });

                                        // 전체 대댓글 개수
                                        ccReplyTotalCount = parseInt(
                                                res.total_count,
                                                10
                                        ) || 0;

                                        // 다음 offset
                                        var nextOffset = parseInt(
                                                res.next_offset,
                                                10
                                        );

                                        ccReplyNextOffset = isNaN(nextOffset)
                                                ? requestOffset + newReplies.length
                                                : nextOffset;

                                        // 다음 페이지 존재 여부
                                        ccReplyHasMore = (
                                                res.has_more === true ||
                                                res.has_more == 1 ||
                                                res.has_more == 'true'
                                        );

                                        ccLog('누적 2차 댓글:', parent.replies.length);
                                        ccLog('전체 2차 댓글:', ccReplyTotalCount);
                                        ccLog('다음 조회 여부:', ccReplyHasMore);
                                        ccLog('다음 offset:', ccReplyNextOffset);
                                        ccLog('========================================');


                                        // ==================================================
                                        // 상세창 댓글 갱신
                                        // ==================================================
                                        current = parent;

                                        // 서버 응답을 받은 후 대댓글 화면 다시 출력
                                        renderReplies(parent, appendMode);

                                        ccLog('========== 대댓글 화면 갱신 ==========');
                                        ccLog('추가 조회:', appendMode);
                                        ccLog('누적 대댓글:', parent.replies.length);
                                        ccLog('전체 대댓글:', ccReplyTotalCount);
                                        ccLog('화면 대댓글 DOM:', $('#ccRepList .cc-rep').length);
                                        ccLog('=======================================');



                                        // 화면 높이보다 댓글이 적어 스크롤이 발생하지 않는 경우도 검사
                                        setTimeout(function() {

                                                ccReplyCheckBottom();

                                        }, 100);


                                        // 부모 댓글 카드의 대댓글 개수 갱신
                                        updateRootReplyCount(
                                                parentNo,
                                                ccReplyTotalCount
                                        );
                                },

                                error: function(xhr, status, error) {

                                        ccLog('2차 댓글 AJAX 오류:', status, error);
                                        ccLog('HTTP 상태:', xhr.status);
                                        ccLog('응답 내용:', xhr.responseText);
                                },

                                complete: function() {

                                        ccReplyLoading = false;
                                        ccReplyMoreAutoClick = false;

                                        $('#ccRepAutoLoading').hide();

                                        ccLog('========== 2차 댓글 요청 완료 ==========');

                                        $('#ccRepSortLoading')
                                                .stop(true, true)
                                                .hide();


                                        // ==================================================
                                        // 조회 중 대기했던 새로고침 실행
                                        // ==================================================

                                        if (ccReplyReloadPending) {

                                                var reloadParentNo = ccReplyReloadParentNo;

                                                ccReplyReloadPending = false;
                                                ccReplyReloadParentNo = 0;

                                                ccLog('대기 중인 2차 댓글 재조회 실행:', reloadParentNo);

                                                if (
                                                        reloadParentNo > 0
                                                        && current
                                                        && parseInt(current.id, 10) == reloadParentNo
                                                ) {

                                                        setTimeout(function() {

                                                                loadMsgDataAfterReply(reloadParentNo, false);

                                                        }, 50);
                                                }
                                        }
                                }

                        });
                }



        // ==================================================
        // Photo 버튼
        // ==================================================
        function makeReplyPhotoButton(item) {

                return $('<a></a>')
                        .attr('href', '#')
                        .addClass('cc-reply-photo text-primary small')
                        .attr('data-rid', item.id)
                        .css({
                                whiteSpace: 'nowrap',
                                flexShrink: 0,
                                fontWeight: 'normal',
                                fontSize: '85%'
                        })
                        .text('Photo');
        }

        // ==================================================
        // 댓글 삭제 버튼
        // ==================================================
        function makeReplyDeleteButton(item) {

                if (!item.can_delete) {
                        return $('<span></span>');
                }

                return $('<a></a>')
                        .attr('href', '#')
                        .addClass('cc-reply-delete text-danger small ms-2')
                        .attr('data-rid', item.id)
                        .text('Delete');
        }






        // ==================================================
        // Photo 이미지 업로드 툴팁
        // Gmail 로그인 확인 + 미리보기 Crop + 서버 업로드
        // ==================================================
        $(document)
                .off('click.ccReplyPhoto')
                .on('click.ccReplyPhoto', '.cc-reply-photo', function(e) {

                        e.preventDefault();
                        e.stopPropagation();

                        var $btn = $(this);

                        // ==================================================
                        // 기존 로그인 안내 툴팁 제거 및 이벤트 해제
                        // ==================================================

                        $('.cc-photo-login-tooltip').remove();

                        $(document).off('click.ccPhotoLoginTooltip');
                        $(window).off('scroll.ccPhotoLoginTooltip');

                        // ==================================================
                        // Gmail 로그인 확인
                        // ==================================================

                        var sgn = getCookie('_sgn_');

                        // ==================================================
                        // 로그인하지 않은 경우
                        // ==================================================

                        if (!sgn) {

                                $('#ccPhotoTooltip').remove();

                                var $loginTooltip = $('<div></div>')
                                        .addClass('cc-photo-login-tooltip')
                                        .css({
                                                position: 'fixed',
                                                zIndex: 999999,
                                                width: '280px',
                                                maxWidth: 'calc(100vw - 20px)',
                                                boxSizing: 'border-box',
                                                padding: '12px',
                                                background: '#fff',
                                                color: '#222',
                                                border: '1px solid #ddd',
                                                borderRadius: '8px',
                                                boxShadow: '0 3px 12px rgba(0,0,0,0.18)'
                                        });

                                $loginTooltip.append(
                                        $('<div></div>')
                                                .text('To add photos, sign in with Google.')
                                                .css({
                                                        fontSize: '13px',
                                                        marginBottom: '12px'
                                                })
                                );

                                // ==================================================
                                // Cancel / Login 버튼 영역
                                // Upload Photo 툴팁과 동일한 버튼 모양
                                // ==================================================

                                var $footer = $('<div></div>').css({
                                        display: 'flex',
                                        alignItems: 'center',
                                        justifyContent: 'flex-end',
                                        gap: '8px',
                                        width: '100%',
                                        marginTop: '8px'
                                });

                                // Cancel
                                var $cancel = $('<button type="button">Cancel</button>')
                                        .css({
                                                border: '1px solid #ccc',
                                                borderRadius: '5px',
                                                padding: '4px 12px',
                                                fontSize: '12px',
                                                background: '#fff',
                                                cursor: 'pointer'
                                        });

                                // Login
                                var $login = $('<button type="button">Login</button>')
                                        .css({
                                                border: '1px solid #0d6efd',
                                                borderRadius: '5px',
                                                padding: '4px 14px',
                                                fontSize: '12px',
                                                color: '#fff',
                                                background: '#0d6efd',
                                                cursor: 'pointer'
                                        });

                                $footer.append($cancel, $login);

                                $loginTooltip.append($footer);

                                $('body').append($loginTooltip);

                                // ==================================================
                                // 위치 계산
                                // Photo 버튼 오른쪽 끝에 맞춤
                                // ==================================================

                                var rect = $btn[0].getBoundingClientRect();

                                var tooltipWidth = $loginTooltip.outerWidth();
                                var tooltipHeight = $loginTooltip.outerHeight();

                                var left = rect.right - tooltipWidth;

                                left = Math.max(
                                        10,
                                        Math.min(
                                                left,
                                                $(window).width() - tooltipWidth - 10
                                        )
                                );

                                var top = rect.top - tooltipHeight - 8;

                                if (top < 10) {
                                        top = rect.bottom + 8;
                                }

                                top = Math.min(
                                        top,
                                        $(window).height() - tooltipHeight - 10
                                );

                                top = Math.max(10, top);

                                $loginTooltip.css({
                                        left: left + 'px',
                                        top: top + 'px'
                                });

                                // ==================================================
                                // 로그인 툴팁 닫기
                                // ==================================================

                                function closeLoginTooltip() {

                                        $loginTooltip.remove();

                                        $(document).off('click.ccPhotoLoginTooltip');
                                        $(window).off('scroll.ccPhotoLoginTooltip');
                                }

                                // Cancel
                                $cancel.on('click', function(e) {

                                        e.preventDefault();
                                        e.stopPropagation();

                                        closeLoginTooltip();

                                        return false;
                                });

                                // Login
                                $login.on('click', function(e) {

                                        e.preventDefault();
                                        e.stopPropagation();

                                        location.href = 'https://co.cc/login/login.php';

                                        return false;
                                });

                                // 툴팁 내부 클릭은 유지
                                $loginTooltip.on('click', function(e) {
                                        e.stopPropagation();
                                });

                                // 바깥 클릭 시 닫기
                                $(document)
                                        .off('click.ccPhotoLoginTooltip')
                                        .on('click.ccPhotoLoginTooltip', function() {

                                                closeLoginTooltip();
                                        });

                                // 스크롤 시 닫기
                                $(window)
                                        .off('scroll.ccPhotoLoginTooltip')
                                        .on('scroll.ccPhotoLoginTooltip', function() {

                                                closeLoginTooltip();
                                        });

                                return false;
                        }

                        // ==================================================
                        // 로그인한 경우
                        // 아래 기존 Upload Photo 툴팁 코드 실행
                        // ==================================================

                        var replyNo = parseInt($btn.attr('data-rid'), 10) || 0;

                        if (replyNo <= 0) {
                                return false;
                        }

                        $('#ccPhotoTooltip').remove();

                        var selectedFile = null;
                        var previewImage = new Image();
                        var uploadSaving = false;


                        var $tooltip = $('<div id="ccPhotoTooltip"></div>');

                        $tooltip.css({
                                position: 'fixed',
                                zIndex: 999999,
                                width: '240px',
                                maxWidth: 'calc(100vw - 20px)',
                                boxSizing: 'border-box',
                                height: 'auto',
                                minHeight: '0',
                                maxHeight: 'calc(100vh - 20px)',
                                overflowY: 'auto',
                                padding: '5px 10px',
                                background: '#fff',
                                color: '#222',
                                border: '1px solid #ddd',
                                borderRadius: '10px',
                                boxShadow: '0 3px 12px rgba(0,0,0,0.18)'
                        });


                        var $header = $('<div></div>')
                                .text('Upload photo')
                                .css({
                                        fontSize: '12px',
                                        fontWeight: '700',
                                        marginBottom: '12px'
                                });


                        var $file = $('<input type="file" accept="image/*">')
                                .css({
                                        display: 'block',
                                        width: '100%',
                                        fontSize: '12px',
                                        lineHeight: '1.5'
                                });

                        $file.css({
                                fontSize: '12px'
                        });

                        $file[0].style.setProperty(
                                'font-size',
                                '12px'
                        );


                        // 미리보기 영역
                        var $preview = $('<img>');

                        // 미리보기 영역: 정사각형
                        var $preview = $('<img>');

                        $preview.css({
                                display: 'none',
                                width: '220px',
                                height: '220px',
                                maxWidth: '100%',
                                objectFit: 'cover',
                                marginTop: '12px',
                                marginLeft: 'auto',
                                marginRight: 'auto',
                                borderRadius: '6px',
                                background: '#f5f5f5'
                        });





                        // 최초 하단 Close 버튼 영역
                        var $closeRow = $('<div></div>').css({
                                display: 'flex',
                                justifyContent: 'flex-end',
                                marginTop: '5px'
                        });

                        var $close = $('<button type="button">Close</button>')
                                .css({
                                        border: '1px solid #ccc',
                                        borderRadius: '5px',
                                        padding: '3px 10px',
                                        fontSize: '12px',
                                        background: '#fff',
                                        cursor: 'pointer'
                                });


                        $closeRow.append($close);

                        // 미리보기 하단 Cancel / Submit 영역
                        var $footer = $('<div></div>').css({
                                display: 'flex',
                                alignItems: 'center',
                                justifyContent: 'space-between',
                                width: '100%',
                                marginTop: '8px'
                        });

                        var $cancel = $('<button type="button">Cancel</button>')
                                .css({
                                        border: '1px solid #ccc',
                                        borderRadius: '5px',
                                        padding: '4px 12px',
                                        fontSize: '12px',
                                        background: '#fff',
                                        cursor: 'pointer'
                                });

                        var $submit = $('<button type="button">Submit</button>')
                                .css({
                                        border: '1px solid #0d6efd',
                                        borderRadius: '5px',
                                        padding: '4px 14px',
                                        fontSize: '12px',
                                        color: '#fff',
                                        background: '#0d6efd',
                                        cursor: 'pointer'
                                });

                        // 미리보기 전에는 숨김
                        $footer.hide();

                        $footer.append($cancel, $submit);

                        var $status = $('<div></div>').css({
                                display: 'none',
                                marginTop: '8px',
                                fontSize: '12px',
                                color: '#666'
                        });

                        $tooltip.append(
                                $header,
                                $file,
                                $closeRow,
                                $preview,
                                $footer,
                                $status
                        );









                        $('body').append($tooltip);

                        // 버튼 위치 기준
                        var rect = $btn[0].getBoundingClientRect();

                        var tooltipWidth = $tooltip.outerWidth();
                        var tooltipHeight = $tooltip.outerHeight();

                        var left = rect.left + rect.width - tooltipWidth;

                        left = Math.max(10, left);
                        left = Math.min(
                                left,
                                $(window).width() - tooltipWidth - 10
                        );

                        var maxTop = $(window).height() - tooltipHeight - 10;
                        var top = Math.min(rect.top - 50, maxTop);

                        top = Math.max(10, top);

                        $tooltip.css({
                                left: left + 'px',
                                top: top + 'px'
                        });

                        // ==================================================
                        // 이미지 미리보기
                        // ==================================================

                        $file.on('change', function() {

                                var file = this.files[0];

                                selectedFile = null;
                                $footer.hide();

                                if (!file) {
                                        $preview.hide();
                                        $closeRow.show();
                                        return;
                                }

                                if (!file.type.match(/^image\//)) {

                                        alert('Please select an image file.');

                                        $(this).val('');
                                        $preview.hide();
                                        $footer.hide();
                                        $closeRow.show();

                                        return;
                                }

                                selectedFile = file;

                                var reader = new FileReader();

                                reader.onload = function(ev) {


                                        previewImage.onload = function() {

                                                $preview
                                                        .attr('src', ev.target.result)
                                                        .show();

                                                // 기존 Close 버튼 숨김
                                                $closeRow.hide();

                                                // Cancel / Submit 버튼 표시
                                                $footer.show();

                                                // 미리보기 영역을 포함한 전체 높이 + 20px
                                                var newHeight = $tooltip[0].scrollHeight + 20;

                                                $tooltip.css({
                                                        height: newHeight + 'px',
                                                        minHeight: '0'
                                                });

                                                // 높이 변경 후 화면 안에 위치하도록 재조정
                                                var rect = $btn[0].getBoundingClientRect();
                                                var tooltipWidth = $tooltip.outerWidth();
                                                var tooltipHeight = $tooltip.outerHeight();

                                                var left = rect.left + rect.width - tooltipWidth;

                                                left = Math.max(10, left);
                                                left = Math.min(
                                                        left,
                                                        $(window).width() - tooltipWidth - 10
                                                );

                                                var maxTop = $(window).height() - tooltipHeight - 10;
                                                var top = Math.min(rect.top - 50, maxTop);

                                                top = Math.max(10, top);

                                                $tooltip.css({
                                                        left: left + 'px',
                                                        top: top + 'px'
                                                });

                                                $status.hide();
                                        };


                                        previewImage.onerror = function() {

                                                selectedFile = null;

                                                $preview.hide();
                                                $footer.hide();
                                                $closeRow.show();

                                                alert('Failed to load image.');
                                        };

                                        previewImage.src = ev.target.result;
                                };

                                reader.readAsDataURL(file);
                        });

                        // ==================================================
                        // 중앙 정사각형 Crop → Resize
                        // 500px 초과일 때만 500 x 500으로 축소
                        // 500px 이하는 원본 크기 유지
                        // ==================================================

                        function makeCroppedImage(callback) {

                                var img = previewImage;

                                if (
                                        !img ||
                                        !img.naturalWidth ||
                                        !img.naturalHeight
                                ) {
                                        callback(null);
                                        return;
                                }

                                var imageWidth = img.naturalWidth;
                                var imageHeight = img.naturalHeight;

                                // ==================================================
                                // 1. 중앙 정사각형 Crop 영역 계산
                                // ==================================================

                                var cropSize = Math.min(imageWidth, imageHeight);

                                var sx = (imageWidth - cropSize) / 2;
                                var sy = (imageHeight - cropSize) / 2;

                                // ==================================================
                                // 2. 500px 초과인 경우에만 Resize
                                // ==================================================

                                var outputSize = cropSize;

                                if (cropSize > 500) {
                                        outputSize = 500;
                                }

                                // ==================================================
                                // 3. Canvas 크기 설정
                                // ==================================================

                                var canvas = document.createElement('canvas');

                                canvas.width = outputSize;
                                canvas.height = outputSize;

                                var ctx = canvas.getContext('2d');

                                if (!ctx) {
                                        callback(null);
                                        return;
                                }

                                try {

                                        // ==================================================
                                        // 4. 중앙 Crop → Resize
                                        // ==================================================

                                        ctx.fillStyle = '#ffffff';
                                        ctx.fillRect(0, 0, outputSize, outputSize);

                                        ctx.drawImage(
                                                img,
                                                sx,
                                                sy,
                                                cropSize,
                                                cropSize,
                                                0,
                                                0,
                                                outputSize,
                                                outputSize
                                        );

                                        // ==================================================
                                        // 5. JPEG Blob 생성
                                        // ==================================================

                                        if (!canvas.toBlob) {
                                                callback(null);
                                                return;
                                        }

                                        canvas.toBlob(function(blob) {

                                                if (!blob || blob.size <= 0) {
                                                        callback(null);
                                                        return;
                                                }

                                                console.log(
                                                        'Original:',
                                                        imageWidth + ' x ' + imageHeight
                                                );

                                                console.log(
                                                        'Crop:',
                                                        cropSize + ' x ' + cropSize
                                                );

                                                console.log(
                                                        'Canvas:',
                                                        canvas.width + ' x ' + canvas.height
                                                );

                                                console.log(
                                                        'Blob size:',
                                                        blob.size,
                                                        'bytes'
                                                );

                                                callback(blob);

                                        }, 'image/jpeg', 1.00);

                                } catch (e) {

                                        console.log('Image crop error:', e);

                                        callback(null);
                                }
                        }


                        // ==================================================
                        // Submit - Crop 후 서버 전송
                        // ==================================================
                        $submit.on('click', function(e) {

                                e.preventDefault();
                                e.stopPropagation();

                                if (uploadSaving || !selectedFile) {
                                        return false;
                                }

                                uploadSaving = true;

                                $submit.prop('disabled', true);
                                $close.prop('disabled', true);

                                $submit.text('Processing...');

                                makeCroppedImage(function(blob) {

                                        if (!blob) {

                                                uploadSaving = false;

                                                $submit.prop('disabled', false);
                                                $close.prop('disabled', false);
                                                $submit.text('Submit');

                                                $status
                                                        .text('Failed to crop image.')
                                                        .css('color', '#dc3545')
                                                        .show();

                                                return;
                                        }

                                        // Crop된 이미지 보관
                                        var croppedImage = blob;

                                        var formData = new FormData();

                                        formData.append(
                                                'reply_no',
                                                replyNo
                                        );

                                        formData.append(
                                                'short_code_no',
                                                shortCodeNo
                                        );

                                        formData.append(
                                                'short_code',
                                                shortCode
                                        );

                                        formData.append(
                                                'photo',
                                                croppedImage,
                                                'reply_photo.jpg'
                                        );

                                        $submit.text('Uploading...');

                                        $.ajax({

                                                url: 'https://co.cc/reply/short_call_code_reply_upload_photo_ajax.php',

                                                type: 'POST',

                                                data: formData,

                                                processData: false,

                                                contentType: false,

                                                dataType: 'json',

                                                xhrFields: {
                                                        withCredentials: true
                                                },

                                                success: function(res) {

                                                        ccLog('Photo 업로드 응답:', res);

                                                        if (!res || res.proc != 1) {

                                                                $status
                                                                        .text(
                                                                                res && res.mssg
                                                                                        ? res.mssg
                                                                                        : 'Failed to upload photo.'
                                                                        )
                                                                        .css('color', '#dc3545')
                                                                        .show();

                                                                return;
                                                        }

                                                        // ==================================================
                                                        // 업로드한 사진 데이터
                                                        // ==================================================
                                                        var newPhoto = {
                                                                replyNo: parseInt(res.reply_no, 10) || 0,
                                                                photo_no: parseInt(res.photo_no, 10) || 0,
                                                                photo_src: res.photo_src,
                                                                photo_path: res.photo_path,
                                                                width: parseInt(res.width, 10) || 0,
                                                                height: parseInt(res.height, 10) || 0,
                                                                file_size: parseInt(res.file_size, 10) || 0
                                                        };

                                                        var alreadyAdded = false;
                                                        var rootNo = 0;

                                                        // ==================================================
                                                        // 1차 댓글 사진 업로드

                                                        currentId = (
                                                                current && current.id != null
                                                        )
                                                                ? parseInt(current.id, 10)
                                                                : 0;

                                                        var targetReplyNo = parseInt(replyNo, 10) || 0;

                                                        var isRootReply = (
                                                                currentId > 0 &&
                                                                targetReplyNo > 0 &&
                                                                currentId == targetReplyNo
                                                        );

                                                        if (isRootReply) {

                                                                rootNo = replyNo;
                                                                // 상세창의 부모 댓글 데이터 갱신
                                                                if (
                                                                        typeof current !== 'undefined'
                                                                        && parseInt(current.id, 10) == rootNo
                                                                ) {

                                                                        if (!$.isArray(current.photos)) {
                                                                                current.photos = [];
                                                                        }

                                                                        $.each(current.photos, function(_, photo) {

                                                                                if (
                                                                                        parseInt(photo.photo_no, 10)
                                                                                        == newPhoto.photo_no
                                                                                ) {
                                                                                        alreadyAdded = true;
                                                                                        return false;
                                                                                }
                                                                        });

                                                                        if (!alreadyAdded) {

                                                                                current.photos.push(newPhoto);

                                                                                current.photo_count =
                                                                                        (parseInt(current.photo_count, 10) || 0) + 1;
                                                                        }

                                                                        refreshRootPhotos(current);
                                                                }

                                                                // 리스트 데이터도 갱신
                                                                var rootData = getRootMsgData(rootNo);

                                                                if (rootData) {

                                                                        if (!$.isArray(rootData.photos)) {
                                                                                rootData.photos = [];
                                                                        }

                                                                        var rootAlreadyAdded = false;

                                                                        $.each(rootData.photos, function(_, photo) {

                                                                                if (
                                                                                        parseInt(photo.photo_no, 10)
                                                                                        == newPhoto.photo_no
                                                                                ) {
                                                                                        rootAlreadyAdded = true;
                                                                                        return false;
                                                                                }
                                                                        });

                                                                        if (!rootAlreadyAdded) {

                                                                                rootData.photos.unshift(newPhoto);

                                                                                rootData.photo_count =
                                                                                        (parseInt(rootData.photo_count, 10) || 0) + 1;
                                                                        }

                                                                        updateRootPhotoCount(
                                                                                rootNo,
                                                                                rootData.photo_count
                                                                        );
                                                                }
                                                        }



                                                        // ==================================================
                                                        // 2차 댓글 사진 업로드
                                                        // ==================================================
                                                        else {

                                                                rootNo = parseInt(current.id, 10) || 0;

                                                                if ($.isArray(current.replies)) {

                                                                        $.each(current.replies, function(_, rp) {

                                                                                if (parseInt(rp.id, 10) != parseInt(replyNo, 10)) {
                                                                                        return;
                                                                                }

                                                                                if (!$.isArray(rp.photos)) {
                                                                                        rp.photos = [];
                                                                                }

                                                                                var alreadyAdded = false;

                                                                                $.each(rp.photos, function(_, photo) {

                                                                                        if (
                                                                                                parseInt(photo.photo_no, 10)
                                                                                                == newPhoto.photo_no
                                                                                        ) {
                                                                                                alreadyAdded = true;
                                                                                                return false;
                                                                                        }
                                                                                });

                                                                                if (!alreadyAdded) {

                                                                                        rp.photos.push(newPhoto);

                                                                                        rp.photo_count =
                                                                                                (parseInt(rp.photo_count, 10) || 0) + 1;
                                                                                }

                                                                                return false;
                                                                        });
                                                                }

                                                                // 2차 댓글 목록 다시 출력
                                                                renderReplies(current);
                                                        }


                                                        // ==================================================
                                                        // 부모 댓글 카드 5초간 강조
                                                        // ==================================================
                                                        blinkRootReplyCard(rootNo);

                                                        // ==================================================
                                                        // 업로드 성공 메시지
                                                        // ==================================================
                                                        $status
                                                                .text('Photo uploaded successfully.')
                                                                .css('color', '#198754')
                                                                .show();

                                                        // 업로드 성공 시 툴팁 닫기
                                                        setTimeout(function() {
                                                                $tooltip.remove();
                                                        }, 700);
                                                },


                                                error: function(xhr, status, error) {

                                                        ccLog('Photo 업로드 오류:', status, error);
                                                        ccLog('서버 응답:', xhr.responseText);

                                                        $status
                                                                .text('Failed to upload photo.')
                                                                .css('color', '#dc3545')
                                                                .show();
                                                },

                                                complete: function() {

                                                        uploadSaving = false;

                                                        $submit.prop('disabled', false);
                                                        $close.prop('disabled', false);

                                                        $submit.text('Submit');
                                                }
                                        });
                                });

                                return false;
                        });

                        // ==================================================
                        // 닫기
                        // Photo 미리보기 + 기존 작은 툴팁 함께 제거
                        // ==================================================
                        function closePhotoTooltip() {

                                // Photo 업로드 미리보기 툴팁 제거
                                $tooltip.remove();

                                // 기존 작은 안내 툴팁 제거
                                $('.cc-author-tooltip').remove();

                                // Photo 툴팁 관련 이벤트 해제
                                $(document).off('click.ccPhotoTooltip');
                                $(window).off('scroll.ccPhotoTooltip');
                        }


                        // ==================================================
                        // Close 버튼
                        // ==================================================
                        $close.off('click').on('click', function(e) {

                                e.preventDefault();
                                e.stopPropagation();

                                if (uploadSaving) {
                                        return false;
                                }

                                closePhotoTooltip();

                                return false;
                        });



                        // ==================================================
                        // Close 버튼
                        // ==================================================
                        $close.on('click', function(e) {

                                e.preventDefault();
                                e.stopPropagation();

                                if (uploadSaving) {
                                        return false;
                                }

                                $tooltip.remove();

                                return false;
                        });



                        // ==================================================
                        // Cancel 버튼
                        // 미리보기 취소 시 Photo 툴팁 전체 닫기
                        // ==================================================
                        $cancel
                                .off('click.ccPhotoCancel')
                                .on('click.ccPhotoCancel', function(e) {

                                        e.preventDefault();
                                        e.stopPropagation();

                                        if (uploadSaving) {
                                                return false;
                                        }

                                        closePhotoTooltip();

                                        return false;
                                });




                        // 외부 클릭 / 스크롤 닫기
                        $(document)
                                .off('click.ccPhotoTooltip')
                                .on('click.ccPhotoTooltip', function(ev) {

                                        if ($(ev.target).closest('#ccPhotoTooltip').length) {
                                                return;
                                        }

                                        closePhotoTooltip();
                                });

                        $(window)
                                .off('scroll.ccPhotoTooltip')
                                .on('scroll.ccPhotoTooltip', function() {

                                        closePhotoTooltip();
                                });

                        return false;
                });




        // ==================================================
        // 댓글 삭제 AJAX
        // 해당 댓글 카드만 삭제하고 전체 재조회하지 않음
        // ==================================================
        $(document)
                .off('click.ccReplyDelete', '.cc-reply-delete')
                .on('click.ccReplyDelete', '.cc-reply-delete', function(e) {

                e.preventDefault();
                e.stopPropagation();

                var $btn = $(this);
                var replyNo = parseInt($btn.attr('data-rid'), 10);

                if (!replyNo) {
                        return false;
                }

                // 2차 댓글인지 확인
                var $replyCard = $btn.closest('.cc-rep');
                var isSecondReply = $replyCard.length > 0;

                // 2차 댓글의 부모 번호
                var parentNo = isSecondReply && current
                        ? parseInt(current.id, 10)
                        : 0;

                // 삭제 확인 툴팁
                if (!$btn.data('deleteConfirmed')) {

                        showDeleteConfirmTooltip($btn, replyNo);

                        return false;
                }

                $btn.removeData('deleteConfirmed');

                // 중복 클릭 방지
                if ($btn.data('deleting')) {
                        return false;
                }

                $btn.data('deleting', true);

                $.ajax({

                        url: 'https://co.cc/reply/short_call_code_reply_delete_ajax.php',

                        type: 'POST',

                        data: {
                                r_no: replyNo,
                                short_code_no: shortCodeNo,
                                short_code: shortCode
                        },

                        xhrFields: {
                                withCredentials: true
                        },

                        dataType: 'json',

                        success: function(res) {

                                ccLog('댓글 삭제 응답:', res);

                                if (!res || res.proc != 1) {

                                        showMsgErrorTooltip(
                                                $btn,
                                                res && res.mssg
                                                        ? res.mssg
                                                        : 'Failed to delete comment.'
                                        );

                                        return;
                                }

                                // ==================================================
                                // 2차 댓글 삭제
                                // ==================================================
                                if (isSecondReply) {

                                        var parent = findMsg(parentNo);

                                        if (!parent) {
                                                return;
                                        }

                                        // 해당 2차 댓글 카드만 제거
                                        $replyCard.remove();

                                        // 내부 2차 댓글 데이터만 제거
                                        var oldReplyLength = parent.replies.length;

                                        parent.replies = $.grep(
                                                parent.replies,
                                                function(item) {
                                                        return parseInt(item.id, 10) != replyNo;
                                                }
                                        );

                                        // 실제 삭제된 항목이 로컬 데이터에 있었는지 확인
                                        var deletedFromLoaded = (
                                                parent.replies.length < oldReplyLength
                                        );

                                        if (deletedFromLoaded) {

                                                ccReplyTotalCount = Math.max(
                                                        0,
                                                        ccReplyTotalCount - 1
                                                );

                                                ccReplyVisibleCount = Math.max(
                                                        0,
                                                        ccReplyVisibleCount - 1
                                                );

                                                // 다음 페이지 offset 보정
                                                if (ccReplyHasMore) {
                                                        ccReplyNextOffset = Math.max(
                                                                0,
                                                                ccReplyNextOffset - 1
                                                        );
                                                }
                                        }

                                        // 부모 댓글의 2차 댓글 수 갱신
                                        parent.reply_count = ccReplyTotalCount;

                                        updateRootReplyCount(
                                                parentNo,
                                                ccReplyTotalCount
                                        );

                                        // 상세창 Replies count만 갱신
                                        $('#ccRepHead > span').first().text(
                                                ccReplyTotalCount > 0
                                                        ? 'Replies (' + ccReplyTotalCount + ')'
                                                        : 'Replies'
                                        );

                                        // 2차 댓글이 모두 없어졌을 때
                                        if (ccReplyTotalCount <= 0) {

                                                $('#ccRepList .cc-rep').remove();

                                                $('#ccRepList').append(
                                                        '<div class="cc-rep-empty">No replies yet. Be the first!</div>'
                                                );

                                                ccReplyHasMore = false;
                                                ccReplyNextOffset = 0;

                                        } else {

                                                $('#ccRepList .cc-rep-empty').remove();
                                        }

                                        ccLog('2차 댓글 삭제 완료');
                                        ccLog('부모 댓글:', parentNo);
                                        ccLog('삭제 댓글:', replyNo);
                                        ccLog('남은 2차 댓글:', ccReplyTotalCount);

                                        return;
                                }

                                // ==================================================
                                // 1차 댓글 삭제
                                // ==================================================

                                // 상세창에서 현재 열려 있는 1차 댓글을 삭제한 경우 닫기
                                if (
                                        current &&
                                        parseInt(current.id, 10) == replyNo
                                ) {
                                        closeView();
                                        current = null;
                                }


                                // ==================================================
                                // 해당 1차 댓글 카드 제거
                                // 카드 사이 빈 공간 방지
                                // ==================================================
                                var $targetCard = $('#ccMsgList .cc-msg-card').filter(function() {

                                        return parseInt($(this).attr('data-id'), 10) == replyNo;

                                }).first();

                                if ($targetCard.length) {

                                        var $cardParent = $targetCard.parent();

                                        $targetCard.remove();

                                        // 빈 래퍼 제거
                                        if (
                                                $cardParent.length &&
                                                $cardParent.children().length == 0 &&
                                                $.trim($cardParent.text()) == ''
                                        ) {
                                                $cardParent.remove();
                                        }
                                }

                                // ==================================================
                                // 내부 1차 댓글 데이터만 제거
                                // ==================================================
                                var oldRootLength = ccMsgData.length;

                                ccMsgData = $.grep(
                                        ccMsgData,
                                        function(item) {
                                                return parseInt(item.id, 10) != replyNo;
                                        }
                                );

                                var deletedRoot = (
                                        ccMsgData.length < oldRootLength
                                );

                                if (deletedRoot) {

                                        // 전체 1차 댓글 수 감소
                                        ccMsgTotalCount = Math.max(
                                                0,
                                                ccMsgTotalCount - 1
                                        );

                                        // 다음 페이지 offset 보정
                                        if (ccMsgHasMore) {
                                                ccMsgNextOffset = Math.max(
                                                        0,
                                                        ccMsgNextOffset - 1
                                                );
                                        }

                                        // 댓글 수 표시 갱신
                                        $('#ccMsgCount').text(
                                                '(' + ccMsgTotalCount + ')'
                                        );

                                        // 댓글이 없으면 새로고침
                                        if (ccMsgTotalCount <= 0)
                                        {
                                                window.location.reload();
                                                return;
                                        }

                                }

                                ccLog('1차 댓글 삭제 완료');
                                ccLog('삭제 댓글:', replyNo);
                                ccLog('남은 로컬 1차 댓글:', ccMsgData.length);
                                ccLog('전체 1차 댓글 수:', ccMsgTotalCount);


                        },

                        error: function(xhr, status, error) {

                                ccLog('삭제 AJAX 오류:', status, error);
                                ccLog('서버 응답:', xhr.responseText);

                                showMsgErrorTooltip(
                                        $btn,
                                        'Failed to delete comment.'
                                );
                        },

                        complete: function() {

                                $btn.data('deleting', false);
                        }

                });

                return false;
        });


        // ==================================================
        // 1차 댓글 카드 5초 Danger 깜빡임
        // ==================================================
        function blinkRootReplyCard(rootNo) {

                rootNo = parseInt(rootNo, 10) || 0;

                if (rootNo <= 0) {
                        return;
                }

                var $card = $('.cc-msg-card[data-id="' + rootNo + '"]');

                if (!$card.length) {
                        return;
                }

                var oldTimer = $card.data('blinkTimer');

                if (oldTimer) {
                        clearTimeout(oldTimer);
                }

                $card.removeClass('cc-card-danger-blink');

                // 애니메이션 재시작
                void $card[0].offsetWidth;

                $card.addClass('cc-card-danger-blink');

                var timer = setTimeout(function() {

                        $card.removeClass('cc-card-danger-blink');

                        $card.removeData('blinkTimer');

                }, 5000);

                $card.data('blinkTimer', timer);
        }


        // ==================================================
        // 1차 댓글 사진 개수 갱신
        // ==================================================
        function updateRootPhotoCount(rootNo, photoCount) {

                rootNo = parseInt(rootNo, 10) || 0;
                photoCount = parseInt(photoCount, 10) || 0;

                var $card = $('.cc-msg-card[data-id="' + rootNo + '"]');

                if (!$card.length) {
                        return;
                }

                var $stat = $card.find('.cc-photo-stat[data-rid="' + rootNo + '"]');

                if (photoCount <= 0) {

                        $stat.remove();

                        return;
                }

                if (!$stat.length) {

                        $stat = $('<span class="cc-stat cc-photo-stat" aria-label="Photos"></span>')
                                .attr('data-rid', rootNo);

                        $stat.append(
                                $(PHOTO).css({
                                        width: '18px',
                                        height: '18px',
                                        flexShrink: 0
                                })
                        );

                        $stat.append(
                                $('<span class="cc-photo-count"></span>')
                                        .text(photoCount)
                        );

                        $card.find('.cc-msg-foot').find('.cc-stat').last().after($stat);

                } else {

                        $stat.find('.cc-photo-count').text(photoCount);
                }
        }





        // ==================================================
        // 첨부 사진 삭제
        // ==================================================

        $(document)
                .off('click.ccPhotoDelete', '.cc-photo-delete')
                .on('click.ccPhotoDelete', '.cc-photo-delete', function(e) {

                        e.preventDefault();
                        e.stopPropagation();

                        var $btn = $(this);

                        var photoNo = parseInt($btn.attr('data-photo-no'), 10) || 0;

                        var $item = $btn.closest('.cc-rep-photo-item');

                        var replyNo = parseInt($item.attr('data-reply-no'), 10) || 0;

                        var isRoot = $item.attr('data-root') == 'y';

                        if (photoNo <= 0 || replyNo <= 0) {
                                return false;
                        }

                        // ==================================================
                        // 기존 댓글 삭제 툴팁 사용
                        // ==================================================

                        if (!$btn.data('deleteConfirmed')) {

                                showDeleteConfirmTooltip(
                                        $btn,
                                        replyNo,
                                        'Delete this photo?'
                                );

                                return false;
                        }

                        // 확인 버튼을 눌러 다시 실행된 경우
                        $btn.removeData('deleteConfirmed');


                        // 중복 클릭 방지
                        if ($btn.data('deleting')) {
                                return false;
                        }

                        $btn.data('deleting', true);

                        $.ajax({

                                url: 'https://co.cc/reply/short_call_code_reply_photo_delete_ajax.php',

                                type: 'POST',

                                dataType: 'json',

                                xhrFields: {
                                        withCredentials: true
                                },
                                data: {
                                        photo_no: photoNo,
                                        short_code_no: shortCodeNo,
                                        short_code: shortCode
                                },

                                success: function(res) {

                                        ccLog(res);

                                        if (!res || parseInt(res.proc, 10) != 1) {

                                                showMsgErrorTooltip(
                                                        $btn,
                                                        res && res.mssg
                                                                ? res.mssg
                                                                : 'Failed to delete photo.'
                                                );

                                                return;
                                        }

                                        // ==================================================
                                        // 선택한 사진만 화면에서 제거
                                        // ==================================================

                                        var $photoList = $item.closest('.cc-rep-photo-list');

                                        $item.remove();

                                        // 사진이 하나도 남지 않으면 사진 영역 제거
                                        if ($photoList.children('.cc-rep-photo-item').length <= 0) {
                                                $photoList.remove();
                                        }

                                        // ==================================================
                                        // 사진 개수 갱신
                                        // ==================================================

                                        if (isRoot) {

                                                // 현재 상세창의 1차 댓글 데이터 갱신
                                                if (
                                                        typeof current !== 'undefined'
                                                        && parseInt(current.id, 10) == replyNo
                                                ) {

                                                        current.photo_count = Math.max(
                                                                0,
                                                                (parseInt(current.photo_count, 10) || 0) - 1
                                                        );

                                                        if ($.isArray(current.photos)) {

                                                                current.photos = $.grep(
                                                                        current.photos,
                                                                        function(photo) {
                                                                                return parseInt(photo.photo_no, 10) != photoNo;
                                                                        }
                                                                );
                                                        }
                                                }

                                                // 목록의 1차 댓글 사진 개수 갱신

                                                var newCount = Math.max(
                                                        0,
                                                        parseInt(current.photo_count, 10) || 0
                                                );

                                                updateRootPhotoCount(replyNo, newCount);


                                        } else {

                                                // ==================================================
                                                // 2차 댓글 데이터 갱신
                                                // ==================================================

                                                if (
                                                        typeof current !== 'undefined'
                                                        && $.isArray(current.replies)
                                                ) {

                                                        $.each(current.replies, function(_, rp) {

                                                                if (parseInt(rp.id, 10) == replyNo) {

                                                                        rp.photo_count = Math.max(
                                                                                0,
                                                                                (parseInt(rp.photo_count, 10) || 0) - 1
                                                                        );

                                                                        if ($.isArray(rp.photos)) {

                                                                                rp.photos = $.grep(
                                                                                        rp.photos,
                                                                                        function(photo) {
                                                                                                return parseInt(photo.photo_no, 10) != photoNo;
                                                                                        }
                                                                                );
                                                                        }

                                                                        return false;
                                                                }
                                                        });
                                                }
                                        }

                                        ccLog('사진 삭제 완료:', photoNo);
                                },

                                error: function(xhr, status, error) {

                                        ccLog('사진 삭제 AJAX 오류:', status, error);

                                        showMsgErrorTooltip(
                                                $btn,
                                                'An error occurred while deleting the photo.'
                                        );
                                },

                                complete: function() {

                                        $btn.data('deleting', false);
                                }
                        });

                        return false;
                });










        // ==================================================
        // 페이지 최초 로딩
        // ==================================================
        window.loadMsgData();


// ==================================================
// 스크롤 시 다음 댓글 자동 조회
// ==================================================
$(window).on('scroll.ccMsgAutoMore', function() {

        if (ccMsgMoreAutoClick) {
                return;
        }

        var $wrap = $('#ccMsgMoreWrap');

        if (!$wrap.length || $wrap.hasClass('d-none') || !$wrap.is(':visible')) {
                return;
        }

        var scrollBottom = $(window).scrollTop() + $(window).height();
        var morePosition = $wrap.offset().top;
        var triggerPosition = morePosition - ($(window).height() * 0.2);

        if (scrollBottom >= triggerPosition) {

                var $btn = $wrap.find('.cc-msg-more').first();

                if (!$btn.length) {
                        return;
                }

                ccMsgMoreAutoClick = true;
                ccMsgMoreAutoLoading = true;

                $('#ccMsgAutoLoading').show();

                $btn.trigger('click');
        }
});



// 빈 댓글 안내 카드 클릭 시 댓글 입력창 열기
$(document).on('click', '.cc-empty', function() {

        $('#ccMsgBar').trigger('click');

});


// ==================================================
// 작성자 링크 클릭 안내 후 새 창 이동
// 상세창 이벤트 차단 (Capture 단계)
// Self 툴팁 5초 유지
// 0.5초 후 새 탭 이동
// ==================================================

function ccAuthorClickCapture(e) {

        var $link = $(e.target).closest('.cc-author-link');

        if (!$link.length) {
                return;
        }

        // 상세창 및 다른 클릭 이벤트 차단
        e.preventDefault();
        e.stopPropagation();
        e.stopImmediatePropagation();

        var url = $link.attr('href');
        var message = $link.attr('data-tooltip');

        // 기존 툴팁 제거
        $('.cc-author-tooltip').remove();

        // 툴팁 생성
        var $tooltip = $('<div></div>')
                .addClass('cc-author-tooltip')
                .css({
                        position: 'absolute',
                        zIndex: 999999,
                        paddingRight: '30px'
                });

        $tooltip.append(
                $('<span></span>').text(message)
        );

        // 닫기 버튼
        var $close = $('<span></span>')
                .text('×')
                .css({
                        position: 'absolute',
                        top: '3px',
                        right: '8px',
                        cursor: 'pointer',
                        fontSize: '18px',
                        fontWeight: 'bold',
                        lineHeight: '18px'
                });

        $tooltip.append($close);

        $('body').append($tooltip);

        var offset = $link.offset();

        $tooltip.css({
                top: offset.top - $tooltip.outerHeight() - 8,
                left: offset.left
        });

        // 0.5초 후 새 탭 이동
        setTimeout(function() {

                window.open(url, '_blank');

        }, 500);

        // 5초 후 툴팁 제거
        var tooltipTimer = setTimeout(function() {

                $tooltip.remove();

        }, 5000);

        // X 클릭 시 툴팁만 즉시 닫기
        $close.on('click', function(e) {

                e.preventDefault();
                e.stopPropagation();

                clearTimeout(tooltipTimer);
                $tooltip.remove();

        });
}

// 기존 동일 이벤트 제거 후 캡처 단계 등록
document.removeEventListener('click', ccAuthorClickCapture, true);
document.addEventListener('click', ccAuthorClickCapture, true);


$(document).on('click', '.cc-vbtn', function(e) {

        e.preventDefault();

        if ($(this).prop('disabled')) {
                return false;
        }

        var dir = parseInt($(this).attr('data-dir'), 10);

        // 기존 댓글 / 대댓글 객체 찾기 및 applyVote() 호출
});


</script>

<script>

// ==================================================
// 페이지 목록 데이터
// ==================================================

var ccActivityData = [];

var ccActivitySort = 'cheers';


// ==================================================
// HTML Escape
// ==================================================

function ccActEsc(value) {

        return $('<div>').text(
                value == null ? '' : String(value)
        ).html();
}


// ==================================================
// 숫자 포맷
// ==================================================

function ccActFmt(n) {

        n = parseInt(n, 10) || 0;

        if (n >= 10000) {
                return Math.round(n / 1000) + 'k';
        }

        if (n >= 1000) {
                return (n / 1000).toFixed(1).replace(/\.0$/, '') + 'k';
        }

        return String(n);
}


// ==================================================
// 시간 표시
// ==================================================

function ccActTime(timestamp) {

        timestamp = parseInt(timestamp, 10) || 0;

        if (timestamp <= 0) {
                return '';
        }

        var diff = Math.floor(Date.now() / 1000) - timestamp;

        if (diff < 60) {
                return 'Just now';
        }

        if (diff < 3600) {
                return Math.floor(diff / 60) + 'm ago';
        }

        if (diff < 86400) {
                return Math.floor(diff / 3600) + 'h ago';
        }

        if (diff < 86400 * 30) {
                return Math.floor(diff / 86400) + 'd ago';
        }

        if (diff < 86400 * 365) {
                return Math.floor(diff / (86400 * 30)) + 'mo ago';
        }

        return Math.floor(diff / (86400 * 365)) + 'y ago';
}


// ==================================================
// 마지막 활동 시간
// ==================================================

function ccActLastAt(p) {

        return Math.max(
                parseInt(p.joinedAt, 10) || 0,
                parseInt(p.visitedAt, 10) || 0
        );
}


// ==================================================
// 새 소식 여부
// ==================================================

function ccActHasNew(p) {

        return (
                (parseInt(p.newPosts, 10) || 0) > 0 ||
                (parseInt(p.newReplies, 10) || 0) > 0
        );
}


// ==================================================
// SVG
// ==================================================

var CC_ACT_HEART =
        '<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">' +
        '<path d="M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1.1-1.1a5.5 5.5 0 0 0-7.8 7.8l1.1 1.1L12 21l7.8-7.5 1.1-1.1a5.5 5.5 0 0 0-.1-7.8z"/>' +
        '</svg>';


// ==================================================
// 페이지 목록 정렬
// ==================================================

function ccActSortedList() {

        var list = ccActivityData.slice(0);

        if (ccActivitySort == 'recent') {

                list.sort(function (a, b) {

                        return ccActLastAt(b) - ccActLastAt(a);
                });

        } else {

                list.sort(function (a, b) {

                        var cheerDiff =
                                (parseInt(b.cheer, 10) || 0) -
                                (parseInt(a.cheer, 10) || 0);

                        if (cheerDiff !== 0) {
                                return cheerDiff;
                        }

                        return ccActLastAt(b) - ccActLastAt(a);
                });
        }

        return list;
}


// ==================================================
// 페이지 HTML 생성
// ==================================================

function ccActRow(p) {

        var slug = p.slug || '';
        var name = p.name || slug;

        var cheer = parseInt(p.cheer, 10) || 0;
        var newPosts = parseInt(p.newPosts, 10) || 0;
        var newReplies = parseInt(p.newReplies, 10) || 0;

        var newAt = parseInt(p.newAt, 10) || 0;
        var visitedAt = parseInt(p.visitedAt, 10) || 0;
        var joinedAt = parseInt(p.joinedAt, 10) || 0;

        var joined = p.joined ? true : false;
        var hasNew = ccActHasNew(p);

        var timeText = '';

        if (joined && joinedAt > 0) {
                timeText = ccActTime(joinedAt);
        } else if (visitedAt > 0) {
                timeText = 'Visited ' + ccActTime(visitedAt);
        }

        var html = '';

        // ------------------------------------------
        // 페이지 카드
        // ------------------------------------------

        html += '<a class="cc-pg' +
                (hasNew ? ' unread' : '') +
                '" href="https://' +
                encodeURIComponent(slug) +
                '.co.cc" data-slug="' +
                ccActEsc(slug) + '">';

        html += '<div class="cc-pg-body">';


        // ------------------------------------------
        // 첫 번째 줄
        // ------------------------------------------

        html += '<div class="cc-pg-row">';

        html += '<div class="cc-pg-url">';

        html += '<span>' +
                ccActEsc(slug) +
                '</span>';

        html += '<span class="cc-td-tld">.co.cc</span>';

        html += '</div>';

        html += '<span class="cc-pg-time">' +
                ccActEsc(timeText) +
                '</span>';

        html += '</div>';


        // ------------------------------------------
        // 두 번째 줄
        // ------------------------------------------

        html += '<div class="cc-pg-row sub">';

        html += '<span class="cc-pg-stat cheer">';

        html += CC_ACT_HEART;

        html += '<span>' +
                ccActFmt(cheer) +
                '</span>';

        html += '</span>';


        // ------------------------------------------
        // 새 소식 배지
        // ------------------------------------------

        if (hasNew) {

                html += '<span class="cc-pg-badges">';

                if (newReplies > 0) {

                        html += '<span class="cc-pg-badge reply">' +
                                'Replied' +
                                '</span>';
                }

                if (newPosts > 0) {

                        html += '<span class="cc-pg-badge post">' +
                                'New' +
                                '</span>';
                }

                html += '</span>';
        }

        html += '</div>';

        html += '</div>';

        html += '</a>';

        return html;
}


// ==================================================
// 페이지 목록 출력
// ==================================================
function renderCcActivityList(sort) {

        if (sort) {
                ccActivitySort = sort;
        }

        var list = ccActSortedList();

        var html = '';

        // ------------------------------------------
        // 새 소식 / 전체 페이지 분리
        // ------------------------------------------

        var fresh = [];
        var rest = [];

        $.each(list, function (i, p) {

                if (ccActHasNew(p)) {
                        fresh.push(p);
                } else {
                        rest.push(p);
                }
        });


        // ------------------------------------------
        // 새 소식 먼저 표시
        // ------------------------------------------

        if (fresh.length > 0) {

                html += '<div class="cc-pg-sep">New activity</div>';

                $.each(fresh, function (i, p) {
                        html += ccActRow(p);
                });
        }


        // ------------------------------------------
        // 나머지 페이지
        // ------------------------------------------

        if (rest.length > 0) {

                if (fresh.length > 0) {
                        html += '<div class="cc-pg-sep">All pages</div>';
                }

                $.each(rest, function (i, p) {
                        html += ccActRow(p);
                });
        }


        // ------------------------------------------
        // 데이터 없음
        // ------------------------------------------

        if (list.length == 0) {

                html = '<div class="cc-act-empty">' +
                        'No pages yet.' +
                        '</div>';
        }


        $('#ccActList').html(html);


        // ------------------------------------------
        // 페이지 개수
        // ------------------------------------------

        $('#ccPgCount').text(list.length);


        // ------------------------------------------
        // 정렬 버튼 상태
        // ------------------------------------------

        $('#ccPgSort button').each(function () {

                var btnSort = $(this).attr('data-sort');

                $(this)
                        .toggleClass('on', btnSort == ccActivitySort)
                        .attr(
                                'aria-selected',
                                btnSort == ccActivitySort ? 'true' : 'false'
                        );
        });
}

// ==================================================
// AJAX 목록 불러오기
// ==================================================

function loadCcActivityList() {

        ccLog('loadCcActivityList sort', ccActivitySort);

        $('#ccActList').html(
                '<div class="text-center py-4 text-muted">' +
                'Loading...' +
                '</div>'
        );

        $.ajax({

                url: 'https://co.cc/reply/short_call_code_activity_list_ajax.php',

                type: 'POST',

                dataType: 'json',

                data: {
                        sort: ccActivitySort
                },

                xhrFields: {
                        withCredentials: true
                },

                cache: false,

                success: function (data) {

                        console.log('[ACTIVITY]', data);

                        if (!data || parseInt(data.proc, 10) !== 1) {

                                ccActivityData = [];

                                $('#ccActList').html(
                                        '<div class="cc-act-empty">' +
                                        'Unable to load pages.' +
                                        '</div>'
                                );

                                $('#ccPgCount').text('0');

                                return;
                        }


                        // ----------------------------------
                        // 목록 저장
                        // ----------------------------------

                        ccActivityData = $.isArray(data.data)
                                ? data.data
                                : [];


                        // ----------------------------------
                        // 목록 출력
                        // ----------------------------------

                        renderCcActivityList(ccActivitySort);


                        // ----------------------------------
                        // 전체 개수
                        // ----------------------------------

                        $('#ccPgCount').text(
                                data.total !== undefined
                                        ? data.total
                                        : ccActivityData.length
                        );

                },

                error: function (xhr, status, error) {

                        console.log('[ACTIVITY ERROR]', status, error);

                        console.log(xhr.responseText);

                        $('#ccActList').html(
                                '<div class="cc-act-empty">' +
                                'Failed to load pages. Please try again.' +
                                '</div>'
                        );

                }

        });
}


// ==================================================
// 서랍 열기
// ==================================================

$(function () {

        // ------------------------------------------
        // 저장된 정렬 방식 불러오기
        // ------------------------------------------

        try {

                var savedSort = localStorage.getItem('cc_pages_sort');

                if (savedSort == 'recent' || savedSort == 'cheers') {
                        ccActivitySort = savedSort;

                        ccLog('cc_pages_sort',ccActivitySort);
                }

        } catch (e) {
                ccActivitySort = 'cheers';
        }


        // ------------------------------------------
        // 서랍 열기
        // ------------------------------------------

        $('#ccActivity')
                .off('show.bs.offcanvas.ccActivity')
                .on('show.bs.offcanvas.ccActivity', function () {

                        loadCcActivityList();

                });


        // ------------------------------------------
        // Most cheers / Recent 정렬 버튼
        // ------------------------------------------

        $('#ccPgSort')
                .off('click.ccActivitySort')
                .on('click.ccActivitySort', 'button', function (e) {

                        e.preventDefault();

                        var sort = $(this).attr('data-sort');

                        if (sort != 'recent' && sort != 'cheers') {
                                return;
                        }

                        ccActivitySort = sort;

                        try {
                                localStorage.setItem('cc_pages_sort', sort);
                        } catch (e) {}

                        // AJAX로 새 목록 불러오기
                        loadCcActivityList();

                });

        // ------------------------------------------
        // 초기 정렬 버튼 상태
        // ------------------------------------------

        $('#ccPgSort button').each(function () {

                var sort = $(this).attr('data-sort');

                $(this)
                        .toggleClass('on', sort == ccActivitySort)
                        .attr(
                                'aria-selected',
                                sort == ccActivitySort ? 'true' : 'false'
                        );
        });

});


// ---- 이름 찾기: 글자·숫자·하이픈만 (한글 OK), 공백 제거, 소문자 → 그 이름.co.cc 로 이동 ----
function cleanName(v) { return String(v).toLowerCase().replace(/\s+/g, '').replace(/[^\p{L}\p{N}-]/gu, '').replace(/^-+|-+$/g, ''); }
$('#ccFind').on('input', function () {
        var c = cleanName(this.value);
        if (c !== this.value) this.value = c;
        $('.cc-find-go').prop('disabled', c.length < 2);
});
$('#ccFindForm').on('submit', function (e) {
        e.preventDefault();
        var t = cleanName($('#ccFind').val());
        if (t.length < 2) return;
        if (typeof gtag === 'function') gtag('event', 'find_name', { page_slug: ccPage.slug, target: t });
        location.href = 'https://' + t + '.co.cc';
});


$(window).on('load', function () {

        if (getCookie('_sgn_')) {
                $('#ccActWho').hide();
                ccLog('ccActWho Close');
        }

});

</script>

<!-- JAVASCRIPT -->
<script src="https://short-img1.cc.cc/js/bootstrap.bundle.min.js"></script>
<script src="https://short-img1.cc.cc/js/bundle.js"></script>

<script>
$(document).ready(function() {

        // 현재 도메인만 남기고 URL 변경
        window.history.replaceState(null, '', window.location.origin);

});

// 2026-11-30 09:32:24</script>
</body>
</html>

