/* 챗봇 */
.lp-chat {
    position: fixed;
    right: 16px;
    bottom: 74px;
    background: rgba(255, 255, 255, 1);
    width: min(95vw, 450px);
    height: calc(100% - 160px);
    overflow: hidden;
    border-radius: 32px;
    z-index: 10;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .1);
    pointer-events: none;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.lp-chat.on {
    visibility: visible;
    pointer-events: auto;
    opacity: 1;
}

.lp-chat.off {
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
}

.lp-chat.lpchat-expanded {
    width: 100%;
    max-width: 1184px;
    height: calc(100% - 160px);
    right: auto;
    left: 50%;
    bottom: 50%;
    background-color: #ffffff;
    border: 0;
    margin: 0;
    transform: translate(-50%, 50%);
    overflow: initial;
}

.lp-chat.lpchat-expanded:after {
    content: '';
    position: fixed;
    display: block;
    left: 50%;
    top: 50%;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: -1;
    transform: translate(-50%, -50%);
}

.chat-output {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: calc(100% - 153px);
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding-bottom: 80px !important;
    background-color: #ffffff;
    padding: 0 12px 24px 24px;
}

.chat-output::-webkit-scrollbar,
.lp-chat form textarea::-webkit-scrollbar {
    width: 12px;
}

.chat-output::-webkit-scrollbar-track,
.lp-chat form textarea::-webkit-scrollbar-track {
    border-radius: 8px;
    background-color: transparent;
}

.chat-output::-webkit-scrollbar-thumb,
.lp-chat form textarea::-webkit-scrollbar-thumb {
    border-radius: 8px;
    background-color: #dfdfdf;
    border: 2px solid #ffffff
}

.chat-output .me {
    padding: 16px 24px;
    background: #fff4ec;
    border-radius: 32px 4px 32px 32px;
    width: fit-content;
    margin-left: auto;
}

.chat-output .lp-turn {
    margin-bottom: 80px;
}

.chat-output:has(.me) .lpchat-starter {
    padding-bottom: 60px;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--gray03);
}

.chat-output .bot {
    padding: 20px;
    border-radius: 24px;
    font-size: 0.98rem;
    line-height: 150%;
}

.chat-header {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 16px;
    border-bottom: 1px solid #efefef;
    background-color: #ffffff;
    position: relative;
    border-radius: 32px 32px 0 0;
    justify-content: end;
    gap: 8px;
}

.chat-header h2 {
    /* display: flex;
    gap: 6px; */
    font-weight: 800;
    font-size: 14px;
    align-items: center;
    position: absolute;
    justify-content: center;
    pointer-events: none;
    left: 0;
    padding-inline: 24px;
    background-image: linear-gradient(to right, rgba(255, 122, 0, 1) 30%, rgb(95 59 152) 60%);
    background-clip: text;
    color: transparent;
}

.lpchat-expanded .chat-header h2 {
    justify-content: flex-start;
}

.chat-header:after {
    content: '';
    position: absolute;
    z-index: 2;
    left: 0;
    bottom: -24px;
    width: 100%;
    height: 24px;
    background: #ffffff;
    background: linear-gradient(0deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
}

.chat-header .logo,
.chat-btn .logo {
    width: 22px;
    aspect-ratio: 1;
    background-image: url(../images/hifenn_logo.svg);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    margin-bottom: 0;
}

.chat-btn .logo {
    width: 32px;
}

.lp-chat form {
    padding: 0 24px 12px 24px;
    position: relative;
    background: #ffffff;
    width: 100%;
    border-radius: 0 0 32px 32px;
}

.lp-chat form::before {
    content: '';
    position: absolute;
    left: 0;
    top: -32px;
    width: 100%;
    height: 32px;
    background: #ffffff;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%)
}

.lp-chat form button {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 32px;
    height: 32px;
    background-color: #ff7a02;
    color: #ffffff;
    border-radius: 32px;
    font-size: 0;
    background-image: url(../images/arrow-up-white.svg);
    background-position: center;
    background-repeat: no-repeat;
    background-size: 24px;
}

.lpchat-send.stop {
    background-color: #f0f0f0;
    cursor: pointer;
    background-image: url(../images/icon_stop.svg);
}

.lp-chat.lpchat-expanded form button {
    right: auto;
    left: calc(100% - 42px);
}

.lp-chat form .textarea-wrap {
    position: relative;
    border: 1px solid transparent;
    font-size: 0;
    border-radius: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    background: linear-gradient(#ffffff, #ffffff) padding-box,
        linear-gradient(-90deg, rgba(0, 118, 255, 1) 0%, rgba(107, 61, 255, 1) 50%, rgba(255, 122, 0, 1) 100%) border-box;
}

.lp-chat form textarea {
    width: 100%;
    border-radius: 20px;
    padding: 14px 48px 14px 20px;
    resize: none;
    min-height: 46px;
    max-height: 200px;
    font-size: 16px;
    border-color: #ffffff;
    overflow: auto;
    position: relative;
}

.lp-chat form textarea::before {
    content: "";
    position: absolute;
    inset: 0;
    padding: 5px;
    background: linear-gradient(to right, #FF4E50, #40C0CB);
    border-radius: inherit;
    z-index: -1;
}

.lp-chat form textarea {
    outline: none;
}

.lp-chat.lpchat-expanded form .textarea-wrap,
.lp-chat.lpchat-expanded .info-desc,
.lp-chat.lpchat-expanded .lpchat-starter,
.lp-chat.lpchat-expanded .chat-output .bot.typing,
.lp-chat.lpchat-expanded .chat-output .bot.error {
    max-width: calc(100% - 352px);
}

/* Quick Actions */
.lp-chat .lpchat-starter .list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 24px;
    background-color: #ffffff;
    align-items: flex-start;
}

.lp-chat .lpchat-starter h1 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
    font-size: 22px;
    font-weight: 700;
    padding: 50px 24px 0;
    text-align: center;
}

.lp-chat .lpchat-starter h1:before {
    content: '';
    display: block;
    width: 24px;
    height: 24px;
    background-image: url(../images/icon_gen_star.svg);
    background-repeat: no-repeat;
    background-size: contain;
}

.lp-chat .lpchat-starter.hidden {
    display: none;
}

.lp-chat .lpchat-qa {
    padding: 10px;
    height: 100%;
    font-size: 14px;
    background: #ffffff;
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    font-weight: 500;
    color: #181818;
    display: flex;
    gap: 12px;
    /* border: 1px solid #efefef; */
}

.lp-chat .lpchat-qa span {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    color: var(--dark-gray02);
    word-break: keep-all;
    white-space: break-spaces;
}

.lp-chat .lpchat-qa:hover {
    filter: brightness(0.98);
}

.chat-output .bot.sources {
    display: none;
}

/* 기본 말풍선 */
.lp-chat .chat-output .me {
    white-space: pre-wrap;
    margin-top: 80px;
}

.lp-chat .chat-output .me:first-child {
    margin-block: 20px;
}

.lp-chat .chat-output .bot.typing {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0;
    font-size: 14px;
    font-weight: 600;
    margin-top: 12px;
    /* 살짝만 간격 */
    min-height: auto;
    /* 전체 화면 차지하지 않도록 */
}

.lp-chat .bot.lpchips {
    padding: 0;
    background: none;
    gap: 4px;
    margin-top: 16px;
    display: flex;
}

.lp-chat.lpchat-expanded .lp-turn {
    display: grid;
    gap: 32px;
    grid-template-columns: 1fr 320px;
}

.lp-chat .lp-right-box,
.lp-chat.lpchat-expanded .lp-left-box .lpchips {
    display: none;
}

.lp-chat.lpchat-expanded .lp-right-box {
    display: block;
}

.lp-chat.lpchat-expanded .lp-right-box .bot.lpchips {
    position: sticky;
    top: 16px;
    padding: 8px;
    background-color: #f9f7fc;
}

.lp-chat .bot.sources {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    margin-top: 10px;
    background: #fff;
}

.lp-chat .bot.sources .src-title {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 8px;
}

.lp-chat .bot.sources .src-list {
    margin: 0;
    padding-left: 18px;
}

.lp-chat .bot.sources .src-list li {
    margin: 4px 0;
}

.lp-chat .bot.sources .src-type {
    font-weight: 600;
    opacity: .8;
}

.lp-chat .bot.sources.empty {
    opacity: .85;
}

/* 인용 링크 */
.lpchat-cite {
    text-decoration: underline;
}

.lpchips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.lpchip {
    display: flex;
    gap: 14px;
    padding: 14px 40px 14px 14px;
    border-radius: 16px;
    text-decoration: none;
    font-size: 14px;
    background: #fff;
    line-height: 140%;
}

.lp-right-box .lpchip {
    border-bottom: 0;
    border-radius: 0;
}

.lp-chat .lp-right-box .bot.lpchips {
    gap: 0;
}

.lp-right-box .lpchip:first-child {
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
}

.lp-right-box .lpchip:last-child {
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
}

.lpchip:hover {
    background: #f9fafb;
}

.lpchip-badge {
    font-weight: 600;
    font-size: 10px;
    opacity: .6;
}

.lpchip .lpchip-text {
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}


/* CTA 패널 */
.lp-chat .chat-output .bot.lpcta {
    padding: 20px 0;
    display: none;
}

.lp-chat .chat-output .lp-turn:last-child .bot.lpcta {
    display: block;
}

.lpcta-title {
    display: none;
}

.lpcta-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.lpcta .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    text-decoration: none;
    font-size: 13px;
    color: #111;
    background: #fff;
}

.lpcta .btn:hover {
    background: #f9fafb;
}

.lpcta .btn.primary {
    border-color: #111;
}

/* 인용 아이콘 앵커 */
.lpchat-cite {
    display: inline-flex;
    vertical-align: text-top;
    margin: 0 2px 0 4px;
    text-decoration: none;
    opacity: .8;
    transition: opacity .15s ease;
    border-radius: 32px;
    padding: 3px;
    background-color: #d4f2d4;
    display: none;
}

.lpchat-cite:hover {
    opacity: 1;
}

.lpchat-cite-ico {
    display: inline-block;
    fill: currentColor;
}


.lpchat-cite[data-cite-type="KB"] {
    color: #2563eb;
}


.lpchat-cite[data-cite-type="W"] {
    color: #7c3aed;
}


.lpchat-cite[data-cite-type="S"] {
    color: #6b7280;
}

.lpjump {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 3;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    background: #ffffff;
    font-size: 13px;
    color: #111;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .08);
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity .15s ease, transform .15s ease;
}

.lpjump.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.chat-output .bot.answer a {
    text-decoration: underline;
}

.chat-output .bot a.lpchip {
    width: 100%;
    align-items: center;
    background-image: url(../images/arrow-black.svg);
    background-position: calc(100% - 12px) center;
    background-size: 20px;
    background-repeat: no-repeat;
    background-color: #f9f7fc;
}

.chat-output .bot a.lpchip:hover {
    background-color: #eeebf2;
}

.lp-chat.lpchat-expanded .chat-output .bot a.lpchip {
    border-bottom: 1px solid #e6ebe6;
    background-color: transparent;
}

.lp-chat.lpchat-expanded .chat-output .bot a.lpchip:last-child {
    border-bottom: 0;
}

.lpchat-reset {
    margin-left: 8px;
    /* padding: 8px 12px 8px 40px; */
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    background: #fff;
    font-size: 13px;
    color: #111;
    cursor: pointer;
    background-image: url(../images/arrow-rotate-left.svg);
    background-position: 9px center;
    background-repeat: no-repeat;
    background-size: 20px;
    overflow: hidden;
    width: 40px;
    height: 40px;
    font-size: 0;
    color: #111111;
    transition: width 0.3s;
    opacity: 0.7;
    white-space: nowrap;
    text-align: left;
}

.lpchat-reset:hover {
    width: 116px;
    font-size: 13px;
    padding: 8px 12px 8px 40px;
    opacity: 0.9;
}

.lpchips .lpchip-thumb {
    width: 60px;
    height: 60px;
    overflow: hidden;
    border-radius: 8px;
    background-image: url(../images/thumb-default.png);
    background-repeat: no-repeat;
    background-size: cover;
}

.lpchips .lpchip-thumb:has(img) {
    width: 60px;
    height: 60px;
}

.lpchips .lpchip-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lpsrc-thumb {
    width: 40px;
    height: 40px;
}

.lpchip-text-box {
    display: flex;
    width: calc(100% - 68px);
    flex-direction: column;
    justify-content: center;
}

.lpchat-resize,
.lpchat-close {
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0;
    background-color: #ffffff;
    background-image: url(../images/arrow-expand-black.svg);
    background-position: center;
    background-repeat: no-repeat;
    background-size: 20px;
}

.lpchat-expanded .lpchat-resize {
    background-image: url(../images/arrow-expand-black-2.svg);
}

.lpchat-close {
    background-image: url(../images/icon_close_black.svg);
    background-size: 22px;
}

.lpchat-size svg {
    display: block;
}

.lp-md {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lp-md-p {}

.lp-md-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

h2.lp-md-h2 {
    font-weight: 800;
    margin-top: 24px;
}

ul.lp-md-list li {
    list-style-type: disc;
    margin-left: 20px;
}

ul.lp-md-list+ol.lp-md-list {
    margin-top: 20px;
}

.lp-chat .bot.answer .lp-md .lp-sec-title {
    font-weight: 700;
    margin: 8px 0 6px;
}

.lp-chat .bot.answer .lp-md .lp-sec-start {
    border-top: 1px solid var(--lp-sep-color, #e5e7eb);
    padding-top: 14px;
    margin-top: 18px;
}

.chat-btn {
    position: fixed;
    z-index: 99;
    right: 24px;
    bottom: 24px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: bottom 0.3s;
    border-radius: 32px;
}

.chat-btn .btn-box {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    gap: 8px;
    border-radius: 32px;
    height: 54px;
    padding-inline: 10px 16px;
    background-color: #ffffff;
    position: relative;
}

.chat-btn .btn-box::before,
.chat-btn .btn-box::after {
    border-radius: 32px;
    content: "";
    position: absolute;
    top: -1px;
    left: -1px;
    background:
        /* linear-gradient(white, white) padding-box, */
        radial-gradient(circle, rgba(0, 118, 255, 1) 0%, rgba(107, 61, 255, 1) 50%, rgba(255, 122, 0, 1) 100%);
    background-size: 300%;
    width: calc(100% + 2px);
    height: calc(100% + 2px);
    z-index: -1;
}

.chat-btn:hover .btn-box::before,
.chat-btn:hover .btn-box::after {
    animation: btn-line-animate 10s linear infinite;
}

.chat-btn:hover .btn-box::after {
    filter: blur(2px);
}

@keyframes btn-line-animate {
    0% {
        background-position: 0 0;
    }

    50% {
        background-position: 300% 300%;
    }

    100% {
        background-position: 0 0;
    }
}

.chat-btn.on {
    width: 40px;
    height: 40px;
    font-size: 0;
    bottom: 24px !important;
    border: 1px solid #181818;
    background: #ffffff url(../images/icon_close_black.svg) no-repeat center !important;
    transition: none;
    display: none;
}

.chat-btn.on .btn-box {
    display: none;
}

footer:has(.btn-to-top.on) .chat-btn {
    bottom: 80px;
    animation: chat-btn-line 0.9s;
}

body:has(.lpchat-expanded) .chat-btn.on {
    right: calc(50% - 580px);
    bottom: 100px !important;
}

.chat-btn:hover {
    animation: chat-btn-line 0.9s;
    animation-iteration-count: infinite !important;
}

.chat-btn .logo {
    background-size: 0;
    animation: logo-spin 0.5s;
    animation-fill-mode: forwards;
    animation-timing-function: ease-in-out;
}

@keyframes chat-btn-line {
    0% {
        background-position: 0 0;
    }

    50% {
        background-position: 300% 0;
    }

    100% {
        background-position: 0 0;
    }
}

@keyframes logo-spin {
    0% {
        filter: blur(4px);
        -webkit-filter: blur(4px);
        background-size: 0;
    }

    100% {
        filter: blur(0);
        -webkit-filter: blur(0);
        background-size: 100%;
        transform: rotate(360deg);
    }
}


.chat-btn .img-box {
    height: 48px;
    /* background-color: var(--green); */
    border-radius: 50%;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;

}

.chat-btn.on .img-box {
    display: none;
}

.loader-box {
    display: flex;
    height: 32px;
    /* <- colon added */
    width: 32px;
    align-items: center;
    justify-content: center;
}

.lp-chat .loader {
    width: 18px;
    height: 18px;
    background-color: var(--green);
    will-change: transform, background-color;
    border-radius: 50%;
}

.lp-chat.lp-chat-loading .loader {
    background:
        radial-gradient(1200px 300px at 20% 0%, rgba(255, 255, 255, .10), transparent 60%),
        linear-gradient(135deg, var(--green), #2563eb 55%, #22c55e);
    animation: rotate 1.5s linear infinite;
}

@keyframes rotate {
    0% {
        transform: rotate(0deg) scale(0.8);
        border-radius: 50%;
    }

    50% {
        transform: rotate(180deg) scale(1.2);
        border-radius: 50%;
    }

    100% {
        transform: rotate(360deg) scale(0.8);
        border-radius: 50%;
    }
}

.lp-chat .info-desc {
    font-size: 13px;
    color: var(--dark-gray02);
    text-align: center;
    margin-top: 10px;
}

.skeleton {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.skeleton .line {
    width: 100%;
    height: 24px;
    border-radius: 32px;
    background: linear-gradient(90deg, #fff4ec 25%, #f9ebe2 37%, #fff4ec 63%);
    background-size: 400% 100%;
    animation: skeleton-loading 1.4s ease infinite;
}

.skeleton .line:last-child {
    width: 60%;
}

@keyframes skeleton-loading {
    0% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0 50%;
    }
}

.chat-output .bot.error {
    border-radius: 24px;
    font-size: 15px;
    color: #aa4400;
    text-align: center;
    background: #fffcde;
    border-radius: 16px;
    opacity: .8;
    margin-block: -80px 80px;
}

.lpchat-notice {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 24px;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .06);
    margin: 10px 0;
    position: absolute;
    left: 24px;
    bottom: 24px;
    z-index: 10;
    width: calc(100% - 48px);
}

.lp-chat.lpchat-expanded .lpchat-notice {
    max-width: calc(100% - 400px);
}

.lpchat-notice.hidden {
    display: none;
}

.lpchat-notice__icon {
    width: 24px;
    aspect-ratio: 1;

    background-image: url(../images/alert-circle.svg);
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
}

.lpchat-notice__title {
    font-weight: 700;
    margin-bottom: 2px;
}

.lpchat-notice__msg {
    color: #374151;
    font-size: 14px;
}

.lpchat-notice__hint {
    color: #6b7280;
    font-size: 12px;
    margin-top: 2px;
}

.lpchat-notice__actions {
    margin-top: 16px;
    display: flex;
    gap: 8px;
}

.lpchat-notice__actions button {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    cursor: pointer;
}

.lpchat-notice__actions button.ghost {
    background: transparent;
}

.bot.typing.fade-out {
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.18s ease-out, transform 0.25s ease-out;
}

.bot.answer.fade-in {
    opacity: 0;
    transform: translateY(6px);
    animation: fadeInUp 0.25s ease-out forwards;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.lpchat-qa .qa-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border: 1px solid #efefef;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    aspect-ratio: 1;
}

.lpchat-qa .qa-icon img {
    width: 18px;
    height: 18px;
}

/* .lpchat-qa .qa-label {
    display: inline-block;
    text-align: left;
} */

@media (max-width: 1280px) {
    .lp-chat {
        width: calc(100% - 16px);
        height: calc(100% - 16px);
        right: 8px;
        bottom: 8px;
    }

    .lpchat-resize {
        display: none;
    }

    .lp-chat .lpchat-starter .list {
        grid-template-columns: 1fr;
    }

    .lp-chat .lpchat-starter h1 {
        font-size: 20px;
    }

}

html[lang="en-US"] .chat-btn,
html[lang="en-US"] .lp-chat {
    pointer-events: none;
    visibility: hidden;
    display: none;
}
