/* 대화(단톡방, 2차 — 사용자 요청 2026-10-15). 화면 높이에 맞춰 고정하고(.page.is-fixed) 대화 칸만 안에서 스크롤한다.
   폰: 방 목록 → 방(뒤로). 900px 이상: 왼쪽 방 목록 + 오른쪽 대화. 색은 토큰만 쓴다(어두운 화면은 따라온다). */

.cht-page.page {
    padding-inline: 8px;
    padding-bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + 6px);
}
@media (min-width: 768px) {
    .cht-page.page { padding-inline: 16px; padding-bottom: 16px; }
}

.cht {
    height: 100%; min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 12px;
}
.cht > .card { margin: 0; min-height: 0; display: flex; flex-direction: column; }
.cht.is-room .cht-rooms { display: none; }
.cht.is-list .cht-pane { display: none; }
@media (min-width: 900px) {
    .cht { grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); }
    .cht.is-room .cht-rooms, .cht.is-list .cht-pane { display: flex; }
}
@media (min-width: 1600px) {
    .cht { grid-template-columns: 360px minmax(0, 1fr); }
}

/* ── 방 목록 ─────────────────────────────────────────────────────── */
.cht-rooms-head { padding: 10px 16px 4px; flex: none; }
.cht-rooms-head .tf-h1 { margin: 4px 0; }
.cht-roomlist { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 6px 8px; }
.cht-room {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 10px;
    border-radius: var(--r-md);
    color: var(--text); text-decoration: none;
    min-width: 0;
}
.cht-room + .cht-room { margin-top: 2px; }
.cht-room.is-sel { background: var(--tf-tint); }
@media (hover: hover) and (pointer: fine) {
    .cht-room:not(.is-sel):hover { background: var(--surface-2); }
}
.cht-room-ico {
    flex: none;
    width: 44px; height: 44px; border-radius: 14px;
    display: grid; place-items: center;
    background: var(--tf-tint); color: var(--tf-deep);
    font-weight: 900; font-size: 17px;
}
.cht-room-ico.is-all { background: var(--tf-deep); color: #fff; font-size: 13px; }
.cht-room-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cht-room-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cht-room-top b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cht-room-top time { margin-left: auto; flex: none; font-size: 11.5px; color: var(--text-3); }
.cht-room-last {
    font-size: 13px; color: var(--text-2);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cht-badge {
    flex: none;
    min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: var(--r-pill);
    background: var(--danger); color: #fff;
    font-size: 11.5px; font-weight: 800; line-height: 20px; text-align: center;
}
.cht-rooms-foot { flex: none; font-size: 12px; padding: 8px 16px 12px; margin: 0; border-top: 1px solid var(--line); }

/* ── 대화 칸 ─────────────────────────────────────────────────────── */
.cht-pane { position: relative; }
.cht-head {
    flex: none;
    display: flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--line);
    min-height: 52px;
}
.cht-title { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cht-count { font-size: 13px; flex: none; }
@media (min-width: 900px) { .cht-back { display: none; } .cht-head { padding-left: 18px; } }

.cht-log {
    flex: 1; min-height: 0;
    overflow-y: auto;
    overflow-anchor: none;              /* 이전 글을 위에 붙일 때 자리는 js 가 지킨다(브라우저 고정과 겹치지 않게) */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 10px 12px 12px;
    background: var(--surface-2);
    display: flex; flex-direction: column;
}
/* 글이 몇 개 없어도 아래에 붙게 */
.cht-log > *:first-child { margin-top: auto; }

.cht-older {
    align-self: center;
    margin: 4px 0 10px;
    border: 1px solid var(--line-strong); background: var(--surface);
    color: var(--text-2); font: inherit; font-size: 12.5px;
    padding: 5px 14px; border-radius: var(--r-pill); cursor: pointer;
}
.cht-start { align-self: center; font-size: 12px; color: var(--text-3); margin: 4px 0 10px; }

.cht-day { display: flex; justify-content: center; margin: 14px 0 8px; }
.cht-day span {
    font-size: 12px; color: var(--text-2);
    background: var(--surface-sunken);
    padding: 3px 12px; border-radius: var(--r-pill);
}
.cht-newline {
    display: flex; align-items: center; gap: 8px;
    margin: 10px 0 6px;
    font-size: 11.5px; color: var(--tf-deep); font-weight: 700;
}
.cht-newline::before, .cht-newline::after { content: ""; flex: 1; height: 1px; background: color-mix(in srgb, var(--tf) 50%, transparent); }

.cht-emptyroom { margin: auto; text-align: center; color: var(--text-2); padding: 24px 12px; }
.cht-emptyroom svg { width: 40px; height: 40px; color: var(--text-3); }
.cht-emptyroom p { margin: 8px 0 0; line-height: 1.6; }
.cht-none { justify-content: center; padding: 16px; }

/* 글 한 편 */
.cht-msg { display: flex; flex-direction: column; align-items: flex-start; margin-top: 10px; max-width: 100%; }
.cht-msg.cont { margin-top: 3px; }
.cht-msg.me { align-items: flex-end; }
.cht-who { font-size: 12.5px; font-weight: 700; color: var(--text-2); margin: 0 0 4px 4px; }
.cht-line { display: flex; align-items: flex-end; gap: 6px; max-width: min(78%, 640px); min-width: 0; }
.cht-msg.me .cht-line { flex-direction: row-reverse; }
@media (max-width: 520px) { .cht-line { max-width: 86%; } }

.cht-bubble {
    min-width: 0;
    padding: 8px 12px;
    border-radius: 4px 16px 16px 16px;
    background: var(--surface);
    box-shadow: var(--sh-1);
    font-size: 14.5px; line-height: 1.5;
    overflow-wrap: anywhere;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.cht-msg.cont .cht-bubble { border-radius: 16px; }
.cht-msg.me .cht-bubble { background: var(--tf-deep); color: #fff; border-radius: 16px 4px 16px 16px; }
.cht-msg.me.cont .cht-bubble { border-radius: 16px; }
.cht-msg.is-sel .cht-bubble { outline: 2px solid var(--hknu-blue-400); outline-offset: 1px; }
.cht-bubble:focus-visible { outline: 2px solid var(--hknu-blue-400); outline-offset: 1px; }
.cht-bubble.is-del { background: none; box-shadow: none; border: 1px dashed var(--line-strong); color: var(--text-3); cursor: default; }
.cht-msg.me .cht-bubble.is-del { background: none; color: var(--text-3); }
.cht-deleted { font-size: 13px; font-style: italic; }
.cht-bubble.is-pic { padding: 4px; }

.cht-text { white-space: pre-wrap; }
.cht-link { color: var(--hknu-blue); text-decoration: underline; text-underline-offset: 2px; }
.cht-msg.me .cht-link { color: inherit; }
.cht-at { font-weight: 800; color: var(--tf-deep); }
.cht-at.is-me { background: color-mix(in srgb, var(--hknu-amber) 35%, transparent); border-radius: 4px; padding: 0 2px; }
.cht-msg.me .cht-at { color: inherit; }

.cht-quote {
    display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
    width: 100%; max-width: 100%;
    margin: 0 0 6px; padding: 4px 8px;
    border: 0; border-left: 3px solid var(--tf);
    background: color-mix(in srgb, var(--text) 6%, transparent);
    border-radius: 6px;
    font: inherit; font-size: 12.5px; text-align: left; color: inherit;
    cursor: pointer;
}
.cht-quote b { font-size: 12px; }
.cht-quote span { opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.cht-msg.me .cht-quote { background: rgba(255, 255, 255, .16); border-left-color: rgba(255, 255, 255, .7); }

.cht-pic { display: block; line-height: 0; }
.cht-pic img {
    display: block;
    max-width: min(260px, 100%); max-height: 260px;
    width: auto; height: auto;
    border-radius: 12px;
    background: var(--surface-sunken);
}
.cht-bubble:not(.is-pic) .cht-pic { margin-bottom: 6px; }

.cht-file {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; margin: 2px 0;
    min-width: 0; max-width: 300px;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--text); text-decoration: none;
}
.cht-msg.me .cht-file { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .3); color: #fff; }
.cht-file-ico { flex: none; font-size: 20px; line-height: 1; }
.cht-file-name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cht-file small { flex: none; font-size: 11.5px; opacity: .75; }
.cht-file.is-gone { opacity: .55; }
.cht-bubble .cht-file + .cht-text { margin-top: 4px; }

.cht-side {
    flex: none;
    display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
    font-size: 11px; color: var(--text-3);
    padding-bottom: 1px;
    white-space: nowrap;
}
.cht-msg.me .cht-side { align-items: flex-end; }
.cht-unread { color: var(--hknu-amber); font-weight: 800; font-size: 11.5px; }
.cht-edited { font-size: 10.5px; }

.cht-acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.cht-acts .btn.sm { background: var(--surface); }
.cht-danger { background: var(--danger); color: #fff; }

@keyframes cht-flash { from { background: color-mix(in srgb, var(--hknu-amber) 40%, transparent); } to { background: transparent; } }
.cht-msg.is-flash { animation: cht-flash 1.6s var(--ease); border-radius: var(--r-md); }
@media (prefers-reduced-motion: reduce) { .cht-msg.is-flash { animation: none; } }

.cht-newbtn {
    position: absolute; left: 50%; transform: translateX(-50%);
    bottom: 84px; z-index: 5;
    border: 0; cursor: pointer;
    background: var(--hknu-blue); color: #fff;
    font: inherit; font-size: 13px; font-weight: 700;
    padding: 7px 16px; border-radius: var(--r-pill);
    box-shadow: var(--sh-2);
}

/* ── 쓰기 ────────────────────────────────────────────────────────── */
.cht-compose {
    flex: none; position: relative;
    border-top: 1px solid var(--line);
    background: var(--surface);
    padding: 6px 8px 8px;
}
.cht-compose .att .req-files { margin: 2px 4px 6px; }
.cht-bar { display: flex; align-items: flex-end; gap: 6px; }
.cht-plus { cursor: pointer; color: var(--up); }
.cht-field { flex: 1; min-width: 0; align-items: flex-end; padding: 0 12px; }
.cht-field textarea { max-height: 160px; line-height: 1.45; padding: 9px 0; font-size: 15px; }
.cht-send {
    flex: none;
    width: 42px; height: 42px; border-radius: 50%;
    border: 0; cursor: pointer;
    background: var(--tf-deep); color: #fff;
    display: grid; place-items: center;
}
.cht-send svg { width: 20px; height: 20px; }
.cht-send.is-busy { opacity: .7; cursor: default; }
.cht-spin {
    width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff;
    animation: cht-spin .8s linear infinite;
}
@keyframes cht-spin { to { transform: rotate(360deg); } }
.cht-status { font-size: 11.5px; color: var(--text-3); padding: 4px 6px 0; }

.cht-mode {
    display: flex; align-items: center; gap: 8px;
    margin: 0 2px 6px; padding: 4px 4px 4px 10px;
    border-radius: var(--r-md);
    background: var(--surface-2);
    font-size: 13px; color: var(--text-2);
}
.cht-mode > svg { flex: none; width: 16px; height: 16px; color: var(--tf-deep); }
.cht-mode-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cht-mode-text b { color: var(--text); margin-right: 4px; }
.cht-mode .iconbtn { min-width: 32px; min-height: 32px; width: 32px; height: 32px; }

.cht-mention {
    position: absolute; left: 52px; bottom: calc(100% - 4px); z-index: 6;
    list-style: none; margin: 0; padding: 4px;
    min-width: 180px; max-width: calc(100% - 64px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--sh-3);
}
.cht-mention li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.cht-mention li.is-on { background: var(--tf-tint); }
@media (hover: hover) and (pointer: fine) { .cht-mention li:hover { background: var(--surface-2); } }

/* 끌어다 놓는 중 */
.cht-pane.dragover::after {
    content: "여기에 놓으면 파일을 보냅니다";
    position: absolute; inset: 0; z-index: 9;
    display: grid; place-items: center;
    background: color-mix(in srgb, var(--up) 14%, transparent);
    border: 2px dashed var(--up); border-radius: var(--r-lg);
    color: var(--up-deep); font-weight: 800;
    pointer-events: none;
}
