@charset "utf-8";

/* 폰트 */
@font-face {
    font-family: 'Freesentation5';
    src: url('https://cdn.jsdelivr.net/gh/fontbee/font@main/Freesentation/Freesentation-4Regular.woff2') format('woff2');
    font-weight: normal;
}
@font-face {
    font-family: 'Paperlogy-4Regular';
    src: url('https://fastly.jsdelivr.net/gh/projectnoonnu/2408-3@1.0/Paperlogy-4Regular.woff2') format('woff2');
    font-weight: 500;
}

/* ===== 기본 ===== */
.chat-skin-wrap {
    margin: 0 auto;
    padding: 20px;
    font-family: 'Freesentation5', sans-serif;
    font-size: 1em;
}

.chat-notice {
    padding: 15px;
    margin-bottom: 20px;
    background: var(--chat-base-color-t);
    border-radius: 10px;
    text-align: center;
    border: 1px solid var(--chat-base-color-auto-t);
}

.chat-layout {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 0;
}

.chat-portrait {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    overflow: visible;
    z-index: 3;
    pointer-events: none;
}

.chat-portrait.left {
    margin-right: -40px;
}

.chat-portrait.right {
    margin-left: -40px;
}

.chat-portrait img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: bottom;
    transition: filter 0.3s, opacity 0.3s;
}

.chat-portrait.left img {
    object-position: bottom right;
}

.chat-portrait.right img {
    object-position: bottom left;
}

.chat-portrait img.inactive {
    filter: brightness(0.6);
}

.chat-portrait img.active {
    filter: brightness(1);
}

.chat-main {
    display: flex;
    flex-direction: column;
    z-index: 2;
    flex-shrink: 0;
}

.chat-load-more {
    padding: 10px;
    text-align: center;
}

.chat-messages {
    padding: 15px 5px;
    overflow-x: hidden;
    overflow-y: auto;
    max-height: calc(100vh - 300px);
    min-height: 250px;
}

/* 커스텀 스크롤바 */
.chat-messages::-webkit-scrollbar {
    width: 10px;
}
.chat-messages::-webkit-scrollbar-track {
    background: var(--chat-base-color-d);
    border-radius: 5px;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: var(--chat-point-color);
    border-radius: 5px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--chat-point-color-tt);
}
.chat-messages {
    scrollbar-width: thin;
    scrollbar-color: var(--chat-point-color) var(--chat-base-color-d);
}

.chat-message {
    margin-bottom: 8px;
    position: relative;
}

.msg-left { display: flex; flex-direction: column; align-items: flex-start; }
.msg-right { display: flex; flex-direction: column; align-items: flex-end; }
.msg-center { display: flex; flex-direction: column; align-items: center; }

/* 이름 */
.msg-name {
    font-size: 0.85em;
    font-weight: 600;
    margin-bottom: 4px;
    padding-left: 8px;
    font-family: 'Paperlogy-4Regular';
}
.msg-right .msg-name {
    padding-left: 0;
    padding-right: 8px;
}

.msg-row {
    display: flex;
    align-items: center;
    gap: 0;
}
.msg-row.left { flex-direction: row; }
.msg-row.right { flex-direction: row; }
.msg-row.center { justify-content: center; }

.chat-bubble {
    max-width: 280px;
    padding: 10px 14px;
    border-radius: 16px;
    word-break: break-word;
    line-height: 1.5;
    box-shadow: 1px 2px 0px var(--chat-base-color-auto-t);
}

img.msg-image,
img.chat-image {
    border-radius: 10px;
    width: 100%;
}

.msg-left .bubble-tail { border-radius: 16px 16px 16px 4px; }
.msg-right .bubble-tail { border-radius: 16px 16px 4px 16px; }

.msg-text { }

.msg-time {
    font-size: 0.7em;
    color: var(--chat-text-color-t);
    white-space: nowrap;
    flex-shrink: 0;
    align-self: flex-end;
    padding: 0 4px;
    font-family: 'Paperlogy-4Regular';
}

.msg-emoticon, .msg-image {
    display: block;
    border-radius: 8px;
}

.msg-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 15px 0;
}
.date-line {
    position: relative;
    width: 100%;
    text-align: center;
}
.date-line::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--chat-base-color-dd);
}
.date-line span {
    position: relative;
    background: var(--chat-base-color);
    padding: 4px 16px;
    border-radius: 20px;
    font-size: 0.85em;
    color: var(--chat-text-color);
    border: 1px solid var(--chat-base-color-dd);
    font-family: 'Paperlogy-4Regular';
}
.date-btns {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    height: 0;
    overflow: hidden;
    opacity: 0;
    transition: height 0.15s, opacity 0.15s, margin 0.15s;
}
.msg-date:hover .date-btns {
    height: 28px;
    opacity: 1;
    margin-top: 6px;
}
.date-btns .msg-btns {
    position: static;
    opacity: 1;
}
.date-edit-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}
.date-edit-wrap input {
    padding: 4px 10px;
    border: 1px solid var(--chat-base-color-dd);
    border-radius: 4px;
    font-size: 0.9em;
    width: 150px;
    text-align: center;
}


.msg-narration {
    display: flex;
    justify-content: center;
    margin: 12px 0;
}
.narration-box {
    flex: 1;
    max-width: 90%;
    padding: 12px 20px;
    border-radius: 8px;
    text-align: center;
    line-height: 1.6;
}
.narration-box.normal {
    background: #e0e0e0;
    color: #555;
    font-style: italic;
}
.narration-box.emphasis {
    background: #222;
    color: #fff;
    font-weight: 500;
}

.msg-btns {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s;
    padding: 0 6px;
}

.msg-row:hover .msg-btns,
.msg-btns:hover {
    opacity: 1;
}

.msg-btns a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: var(--chat-base-color-d);
    color: var(--chat-text-color);
    font-size: 0.65em;
    font-weight: bold;
    text-decoration: none;
}
.msg-btns a:hover {
    background: var(--chat-point-color);
    color: var(--chat-point-color-auto);
}

.no-messages {
    text-align: center;
    padding: 50px 20px;
    color: var(--chat-text-color-t);
}

/* 인라인 수정 */
.edit-area {
    width: 100%;
}

.edit-textarea {
    width: 100%;
    min-height: 60px;
    padding: 8px;
    border: 1px solid var(--chat-base-color-auto-t);
    border-radius: 8px;
    font-size: 0.95em;
    font-family: inherit;
    resize: vertical;
    background: var(--chat-base-color);
    color: var(--chat-text-color);
    box-sizing: border-box;
}

.edit-textarea:focus {
    outline: none;
    border-color: var(--chat-point-color);
}

.edit-btns {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    justify-content: flex-end;
}

.edit-btns .skin-btn {
    padding: 5px 12px;
    font-size: 0.85em;
    margin: 0;
}

/* 수정 시간 입력 */
.edit-time-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    justify-content: flex-end;
}
.edit-time-row select,
.edit-time-row input {
    padding: 4px 8px;
    font-size: 0.85em;
}
.edit-time-row .time-num {
    width: 50px;
    text-align: center;
}

/* 나레이션 수정 시 */
.narration-box .edit-textarea {
    text-align: center;
}

.narration-box.normal .edit-textarea {
    background: #f5f5f5;
    color: #555;
}

.narration-box.emphasis .edit-textarea {
    background: #333;
    color: #fff;
}

.chat-input-area {
    display: flex;
    flex-direction: column;
    margin: 10px auto 0;
}

.input-row {
    position: relative;
    display: flex;
    align-items: flex-end;
    background: var(--chat-base-color-b);
    border-radius: 20px;
    padding: 8px 12px;
    border: 1px solid var(--chat-base-color-auto-t);
}

.input-row textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 1em;
    line-height: 1.5;
    padding: 6px 0;
    font-family: inherit;
    color: var(--chat-text-color);
    min-height: 24px;
    max-height: 120px;
}
.input-row textarea:focus { outline: none; }
.input-row textarea::placeholder { color: var(--chat-text-color-t); }

.input-btns {
    display: flex;
    gap: 4px;
    margin-left: 8px;
}

.icon-btn, .send-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 50%;
    color: var(--chat-text-color-t);
    font-size: 1.1em;
}
.icon-btn:hover { color: var(--chat-point-color); }
.send-btn {
    background: var(--chat-point-color);
    color: var(--chat-point-color-auto);
}
.send-btn:hover { opacity: 0.9; }

.input-options {
    padding: 10px 5px;
}

.option-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.option-row:last-child { margin-bottom: 0; }

.option-row-split {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.option-row-split .option-left {
    display: flex;
    align-items: center;
    gap: 5px;
}
.option-row-split .option-right {
    display: flex;
    align-items: center;
    gap: 3px;
}
.option-row-split .option-left select {
    width: auto;
    min-width: 80px;
}
.option-row-split .option-right select {
    width: auto;
    min-width: 60px;
}
.option-row-split .time-num {
    width: 50px !important;
}

/* 폼 요소 */
.chat-input {
    padding: 8px 12px;
    border: 1px solid var(--chat-base-color-auto-t);
    border-radius: 8px;
    font-size: 0.9em;
    background: var(--chat-base-color);
    color: var(--chat-text-color);
    font-family: inherit;
    height: max-content;
}
.chat-input:focus {
    outline: none;
    border-color: var(--chat-point-color);
}

.time-num { width: 50px; text-align: center; }

input[type="color"] {
    width: 50px;
    height: 30px;
    padding: 2px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

/* ===== 아보카도 스타일 버튼 ===== */
.skin-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 18px;
    border-radius: 5px;
    margin: 4px;
    font-family: inherit;
    border: none;
    cursor: pointer;
    font-size: 0.9em;
}

.popstyle {
    box-shadow: 1px 2px 0px var(--chat-base-color-auto-t);
    transition: 0.3s;
}
.popstyle:hover {
    translate: 1px 1px;
    box-shadow: 0px 1px 0px var(--chat-base-color-auto-t);
}
.popstyle:active {
    translate: 2px 2px;
    box-shadow: 1px 1px 0px var(--chat-base-color-auto-t) inset;
}

.basecolor {
    background: var(--chat-base-color);
    color: var(--chat-text-color);
}
.basecolor:hover { background: var(--chat-text-color); color: var(--chat-base-color); }

.textcolor {
    background: var(--chat-text-color);
    color: var(--chat-base-color);
}
.textcolor:hover { background: var(--chat-base-color); color: var(--chat-text-color); }

.pointcolor2 {
    background: var(--chat-point-color);
    color: var(--chat-base-color);
}
.pointcolor2:hover { background: var(--chat-base-color); color: var(--chat-point-color); }

/* ===== 모달 ===== */
.chat-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    font-family: 'Freesentation5', 'Paperlogy-4Regular', sans-serif;
}
.chat-modal.active { display: flex; }

.modal-box {
    position: relative;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    font-family: 'Freesentation5', 'Paperlogy-4Regular', sans-serif;
}
.modal-box.modal-wide { max-width: 600px; }

.skin-table {
    color: var(--chat-text-color);
    background: linear-gradient(314deg, var(--chat-base-color), transparent 200%);
    backdrop-filter: blur(10px);
    border-collapse: collapse;
    font-size: 1em;
    border-radius: 10px;
    padding: 20px;
    padding-top: 60px;
    font-family: inherit;
    border: 1px solid var(--chat-base-color-auto-t);
    box-shadow: 0px 6px 14px 1px var(--chat-base-color-auto-t);
}

.skin-table .title {
    width: 100%;
    color: var(--chat-text-color);
    position: absolute;
    left: 0;
    top: 0;
    padding: 18px 22px;
    box-sizing: border-box;
    font-size: 1.1em;
    font-weight: 600;
    box-shadow: 0px 7px 8px -10px var(--chat-text-color-auto);
}

.modal-x {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: inherit;
    line-height: 1;
}

.modal-body {
    overflow-y: auto;
    flex: 1;
    max-height: 60vh;
}

.skin-table dl {
    display: flex;
    width: 100%;
    align-items: center;
    margin-bottom: 10px;
}
.skin-table dt {
    min-width: 120px;
    font-weight: bold;
    text-align: center;
    background: var(--chat-text-color);
    color: var(--chat-base-color);
    border-radius: 5px;
    padding: 8px;
}
.skin-table dd {
    flex: 1;
    padding-left: 10px;
}

.modal-btns {
    text-align: right;
    margin-top: 15px;
}

.modal-char-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--chat-base-color-auto-t);
}
.modal-char-row label { font-weight: 500; }
.modal-char-row select { flex: 1; }

.emo-list {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    max-height: 180px;
    overflow-y: auto;
    margin-bottom: 15px;
}
.emo-item {
    aspect-ratio: 1;
    border: 1px solid var(--chat-base-color-auto-t);
    border-radius: 8px;
    cursor: pointer;
    overflow: hidden;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--chat-base-color);
}
.emo-item:hover {
    border-color: var(--chat-point-color);
    transform: scale(1.05);
}
.emo-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.upload-divider {
    text-align: center;
    color: var(--chat-text-color-t);
    font-size: 0.9em;
    margin: 15px 0;
    position: relative;
}
.upload-divider::before, .upload-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 25%;
    height: 1px;
    background: var(--chat-base-color-dd);
}
.upload-divider::before { left: 0; }
.upload-divider::after { right: 0; }

.upload-box {
    border: 2px dashed var(--chat-base-color-dd);
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: 0.2s;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--chat-text-color-t);
}
.upload-box:hover, .upload-box.drag-over {
    border-color: var(--chat-point-color);
    background: var(--chat-point-color-t);
}
.upload-icon { font-size: 2em;
display: block; }

.url-row {
    display: flex;
    gap: 8px;
}
.url-row input { flex: 1; }

.char-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--chat-base-color-auto-t);
    border-radius: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.char-badge {
    padding: 6px 14px;
    border-radius: 5px;
    font-weight: 500;
}
.char-pos {
    font-size: 0.85em;
    color: var(--chat-text-color-tt);
}
.char-expr-count {
    font-size: 0.85em;
    color: var(--chat-point-color);
    margin-left: auto;
}

/* 표정 편집 섹션 */
.expr-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--chat-base-color-auto-t);
}

.expr-section h4 {
    margin: 0 0 10px 0;
    font-size: 1em;
    font-weight: 600;
}

.perm-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--chat-base-color-auto-t);
}

.perm-section h4 {
    margin: 0 0 10px 0;
    font-size: 1em;
    font-weight: 600;
}

.perm-section dl {
    margin-bottom: 10px;
}

.perm-section .desc {
    display: block;
    font-size: 0.85em;
    color: var(--chat-text-color-tt);
    margin-top: 4px;
}

.member-select-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.member-select-wrap select {
    max-width: 250px;
}
.allowed-members-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 24px;
}
.allowed-member-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--chat-base-color-d);
    border-radius: 4px;
    font-size: 0.85em;
}
.allowed-member-tag .remove-member {
    cursor: pointer;
    color: var(--chat-text-color-tt);
    font-weight: bold;
}
.allowed-member-tag .remove-member:hover {
    color: #d33;
}

.expr-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding: 8px;
    background: var(--chat-base-color-b);
    border-radius: 5px;
}

.expr-name {
    min-width: 80px;
    font-weight: 500;
}

.expr-url {
    flex: 1;
    font-size: 0.9em;
}

.expr-add-row {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.expr-add-row input {
    flex: 1;
    min-width: 100px;
}

.img-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.img-input-row input {
    flex: 1;
}

.img-upload-btn {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.img-upload-btn input[type="file"] {
    display: none;
}

.no-expr {
    text-align: center;
    color: var(--chat-text-color-t);
    padding: 15px;
    font-size: 0.9em;
}

/* ===== 반응형 ===== */
@media (max-width: 900px) {
    .chat-portrait {
        width: 120px !important;
    }
}

@media (max-width: 700px) {
    .chat-layout {
        flex-direction: column;
        align-items: center;
    }
    .chat-portrait {
        display: none;
    }
    .chat-main {
        width: 100% !important;
        max-width: 100%;
    }
}

@media (max-width: 550px) {
    .option-row-split {
        flex-direction: column;
        align-items: stretch;
    }
    .option-row-split .option-left,
    .option-row-split .option-right {
        width: 100%;
        justify-content: flex-start;
    }
}
