/* =============================================
   Class Chat - 교사 → 학생 메시지/코드 전달 패널
   메모 패널(.memo-panel)과 같은 오른쪽 슬라이드 형태
   ============================================= */

/* 상단 프로필 옆 아이콘 */
.class-chat-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-right: 8px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    font-size: 17px;
    cursor: pointer;
    vertical-align: middle;
    transition: background 0.2s ease;
}

.class-chat-btn:hover {
    background: rgba(74, 158, 255, 0.18);
}

.class-chat-badge {
    position: absolute;
    top: -4px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #ff4d4f;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-sizing: border-box;
    pointer-events: none;
}

.class-chat-badge.hidden {
    display: none;
}

.class-chat-btn.pulse i {
    animation: chatPulse 0.6s ease 3;
}

@keyframes chatPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); color: #4a9eff; }
}

/* 새 메시지 말풍선 */
.chat-bubble-notice {
    position: fixed;
    z-index: 9600;
    padding: 8px 14px;
    border-radius: 10px;
    background: #4a9eff;
    color: #fff;
    font-size: 13px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

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

/* 패널 */
.chat-panel {
    position: fixed;
    top: 20px;
    right: 0;
    width: 420px;
    max-width: calc(100vw - 20px);
    height: calc(100vh - 40px);
    z-index: 9500;
    display: flex;
    flex-direction: column;
    background: #eef1f5; /* 메시지 목록 배경: 흰 카드가 구분되도록 살짝 진하게 */
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-right: none;
    border-radius: 16px 0 0 16px;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.12), 0 8px 32px rgba(0, 0, 0, 0.08);
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    color: #1a1a1a;
    font-size: 14px;
}

.chat-panel:not(.hidden) {
    transform: translateX(0);
}

.chat-panel.hidden {
    pointer-events: none;
    /* 닫힌 패널 안으로 Tab 포커스가 들어가지 않게 (슬라이드가 끝난 뒤 숨김) */
    visibility: hidden;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0.35s;
}

/* 학생이 채팅에서 [닉네임 설정]을 누르면 프로필 창이 채팅 패널 위에 떠야 한다 */
#studentProfileOverlay {
    z-index: 9600;
}

.chat-panel .hidden {
    display: none !important;
}

.chat-resize-handle {
    position: absolute;
    left: 0;
    top: 16px;
    width: 8px;
    height: calc(100% - 32px);
    cursor: ew-resize;
    z-index: 20;
    border-radius: 16px 0 0 16px;
    touch-action: none;
}

.chat-resize-handle:hover,
.chat-resize-handle.active {
    background: rgba(74, 158, 255, 0.3);
}

.chat-panel.resizing {
    user-select: none;
}

.chat-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 16px 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: #fff;
}

.chat-panel-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    white-space: nowrap;
}

.chat-panel-header h3 i {
    color: #4a9eff;
    margin-right: 4px;
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.chat-icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.05);
    color: rgba(0, 0, 0, 0.6);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.chat-icon-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #000;
}

.chat-clear-btn:hover {
    color: #e5484d;
}

.chat-status {
    padding: 8px 20px;
    background: #fff4e5;
    color: #8a5300;
    font-size: 13px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

/* 메시지 목록 */
.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-empty {
    margin: auto;
    max-width: 280px;
    text-align: center;
    color: #8792a2;
    font-size: 13px;
    line-height: 1.6;
}

.chat-msg {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: 12px;
    padding: 10px 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    animation: chatMsgIn 0.25s ease;
}

@keyframes chatMsgIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-msg-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
    color: #8792a2;
}

.chat-msg-avatar {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    overflow: hidden;
    background: #e8f1ff;
    border: 1px solid rgba(74, 158, 255, 0.35);
    color: #4a9eff;
    font-size: 11px;
}

.chat-msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-msg-tag i {
    margin-right: 2px;
    color: #4a9eff;
}

.chat-msg-actions {
    margin-left: auto;
    display: flex;
    flex: 0 0 auto;
    gap: 4px;
}

/* 좁은 패널에서도 "Python · 14 줄", "복사됨!" 이 두 줄로 꺾이지 않게 */
.chat-msg-head > *,
.chat-msg-actions > * {
    white-space: nowrap;
}

/* 공간이 모자라면 "Python · 2 줄" 보다 시간이 먼저 줄어들고, 그래도 넘치면(학생 메시지의 공유·차단 버튼,
   "학생 질문" 라벨 등) 버튼 줄이 아래로 내려간다 → 닉네임이 가려지거나 목록에 가로 스크롤이 생기지 않음 */
.chat-msg-head {
    flex-wrap: wrap;
    row-gap: 6px;
}

.chat-msg-tag {
    flex: 0 0 auto;
}

.chat-msg-time {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-copy-btn,
.chat-del-btn {
    border: none;
    border-radius: 6px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.05);
    color: #4a5565;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-copy-btn:hover {
    background: #4a9eff;
    color: #fff;
}

.chat-copy-btn.copied {
    background: #2fb36d;
    color: #fff;
}

.chat-del-btn:hover {
    background: #e5484d;
    color: #fff;
}

.chat-text {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.55;
}

.chat-text a {
    color: #2b7de9;
}

/* 코드: 들여쓰기·탭·개행을 그대로 표시 (자동 줄바꿈 없음 → 가로 스크롤)
   코랩/주피터 라이트 테마와 맞춘 밝은 배경 */
/* 스크롤 컨테이너: 줄 번호 열과 코드가 함께 세로 스크롤, 가로 스크롤 시 줄 번호는 고정 */
.chat-code-wrap {
    display: flex;
    align-items: flex-start;
    border: 1px solid #e3e6ea;
    border-radius: 8px;
    background: #f7f8fa;
    overflow: auto;
    max-height: 60vh;
    font-family: 'JetBrains Mono', Consolas, 'D2Coding', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.chat-code-gutter {
    display: none;
    position: sticky;
    left: 0;
    z-index: 1;
    flex: 0 0 auto;
    min-height: 100%;
    padding: 12px 8px 12px 10px;
    border-right: 1px solid #e3e6ea;
    background: #eef0f3;
    color: #9aa3af;
    text-align: right;
    white-space: pre;
    user-select: none;
    -webkit-user-select: none;
}

.show-lines .chat-code-gutter {
    display: block;
}

.chat-code {
    flex: 1 0 auto;
    margin: 0;
    padding: 12px 14px;
    color: #1f2328;
    white-space: pre;
    word-wrap: normal;
    tab-size: 4;
    -moz-tab-size: 4;
    font: inherit;
}

.chat-code code,
.chat-code code.hljs {
    padding: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    white-space: inherit;
}

/* 문법 색상: 구글 코랩 라이트 테마(VS Code Light+)와 같은 배색 */
.chat-code .hljs-comment,
.chat-code .hljs-quote { color: #008000; }
.chat-code .hljs-string,
.chat-code .hljs-char,
.chat-code .hljs-regexp { color: #a31515; }
.chat-code .hljs-subst { color: #1f2328; }
.chat-code .hljs-number { color: #098658; }
.chat-code .hljs-keyword,
.chat-code .hljs-selector-tag { color: #af00db; }
.chat-code .hljs-literal,
.chat-code .hljs-doctag { color: #0000ff; }
.chat-code .hljs-type { color: #267f99; }
.chat-code .hljs-built_in,
.chat-code .hljs-fn-call { color: #795e26; }
.chat-code .hljs-title,
.chat-code .hljs-title.function_,
.chat-code .hljs-title.class_,
.chat-code .hljs-section { color: #795e26; }
.chat-code .hljs-title.class_ { color: #267f99; }
.chat-code .hljs-params,
.chat-code .hljs-variable,
.chat-code .hljs-property,
.chat-code .hljs-attr,
.chat-code .hljs-attribute { color: #001080; }
.chat-code .hljs-meta,
.chat-code .hljs-meta .hljs-keyword { color: #795e26; }
.chat-code .hljs-tag,
.chat-code .hljs-name { color: #800000; }
.chat-code .hljs-symbol,
.chat-code .hljs-bullet,
.chat-code .hljs-link { color: #0451a5; }
.chat-code .hljs-emphasis { font-style: italic; }
.chat-code .hljs-strong { font-weight: 700; }

.chat-new-pill {
    position: absolute;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    padding: 6px 14px;
    border: none;
    border-radius: 999px;
    background: #4a9eff;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 5;
}

.chat-panel.has-composer .chat-new-pill {
    bottom: 200px;
}

/* 교사 작성 영역 */
.chat-composer {
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background: #fff;
    padding: 10px 14px 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-composer-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.chat-mode-toggle {
    display: inline-flex;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px;
}

.chat-mode-toggle button {
    border: none;
    background: transparent;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    color: #4a5565;
    cursor: pointer;
}

.chat-mode-toggle button.active {
    background: #fff;
    color: #1a1a1a;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.chat-lang-select {
    padding: 4px 6px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 6px;
    background: #fff;
    color: #1a1a1a;
    font-size: 12px;
}

.chat-hint {
    font-size: 12px;
    color: #2fb36d;
}

.chat-input {
    width: 100%;
    min-height: 80px;
    max-height: 40vh;
    resize: vertical;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    background: #fff;
    color: #1a1a1a;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    outline: none;
    tab-size: 4;
    -moz-tab-size: 4;
}

.chat-input:focus {
    border-color: #4a9eff;
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.15);
}

.chat-input.code {
    min-height: 140px;
    background: #f7f8fa;
    color: #1f2328;
    white-space: pre;
    overflow-x: auto;
    font-family: 'JetBrains Mono', Consolas, 'D2Coding', 'Courier New', monospace;
    font-size: 13px;
}

.chat-composer-foot {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-shortcut {
    margin-right: auto;
    font-size: 11px;
    color: #8792a2;
}

.chat-attach-btn {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.05);
    color: #4a5565;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-attach-btn:hover {
    background: rgba(74, 158, 255, 0.15);
    color: #2b7de9;
}

.chat-attach-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

/* 보내기 전 첨부 대기 목록 */
.chat-pending {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 160px;
    overflow-y: auto;
}

.chat-pending-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    background: #f7f8fa;
    font-size: 12px;
}

.chat-pending-item img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}

.chat-pending-item > i {
    width: 40px;
    text-align: center;
    font-size: 22px;
    color: #4a9eff;
}

.chat-pending-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #1a1a1a;
}

.chat-pending-size {
    color: #8792a2;
}

.chat-pending-item button {
    border: none;
    background: transparent;
    color: #8792a2;
    cursor: pointer;
    padding: 4px 6px;
}

.chat-pending-item button:hover {
    color: #e5484d;
}

/* 드래그 앤 드롭 */
.chat-drop-overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(74, 158, 255, 0.12);
    border: 3px dashed #4a9eff;
    border-radius: 16px 0 0 16px;
    pointer-events: none;
}

.chat-drop-overlay > div {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 28px;
    border-radius: 12px;
    background: #fff;
    color: #2b7de9;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.chat-drop-overlay i {
    font-size: 30px;
}

/* 이미지 메시지 */
.chat-image img {
    display: block;
    max-width: 100%;
    max-height: 360px;
    height: auto; /* width/height 속성으로 로드 전에도 비율만큼 자리 확보 */
    border-radius: 8px;
    border: 1px solid #e3e6ea;
    background: #f7f8fa;
    cursor: zoom-in;
    object-fit: contain;
}

/* 파일 메시지 */
.chat-file {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #e3e6ea;
    border-radius: 8px;
    background: #f7f8fa;
}

.chat-file-icon {
    font-size: 28px;
    color: #4a9eff;
}

.chat-file-icon.ext-pdf { color: #e5484d; }
.chat-file-icon.ext-xlsx, .chat-file-icon.ext-xls, .chat-file-icon.ext-csv { color: #2fb36d; }
.chat-file-icon.ext-pptx, .chat-file-icon.ext-ppt { color: #e8772e; }
.chat-file-icon.ext-docx, .chat-file-icon.ext-doc { color: #2b7de9; }

.chat-file-info {
    flex: 1;
    min-width: 0;
}

.chat-file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
    color: #1a1a1a;
}

.chat-file-size {
    margin-top: 2px;
    font-size: 12px;
    color: #8792a2;
}

.chat-file-open {
    padding: 5px 10px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 6px;
    background: #fff;
    color: #4a5565;
    font-size: 12px;
    text-decoration: none;
    white-space: nowrap;
}

.chat-file-open:hover {
    border-color: #4a9eff;
    color: #2b7de9;
}

.chat-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: 6px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.05);
    color: #4a5565;
    font-size: 12px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.chat-download-btn:hover {
    background: #4a9eff;
    color: #fff;
}

/* 이미지 크게 보기 */
.chat-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9700;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px;
    background: rgba(0, 0, 0, 0.82);
    cursor: zoom-out;
}

.chat-lightbox.hidden {
    display: none;
}

.chat-lightbox img {
    max-width: 100%;
    max-height: calc(100vh - 110px);
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.chat-lightbox .chat-download-btn {
    padding: 8px 16px;
    background: #fff;
    color: #1a1a1a;
    font-size: 14px;
}

.chat-send-btn {
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    background: #4a9eff;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.chat-send-btn:hover {
    background: #2b7de9;
}

.chat-send-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

/* 공유 메모 안내 카드 */
.chat-memo-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #f1dfb0;
    border-radius: 8px;
    background: #fffaeb;
}

.chat-memo-icon {
    font-size: 26px;
    color: #e6a700;
}

.chat-memo-info {
    flex: 1;
    min-width: 0;
}

.chat-memo-label {
    font-size: 11px;
    color: #a07a00;
}

.chat-memo-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
    color: #1a1a1a;
}

button.chat-file-open {
    cursor: pointer;
    font-family: inherit;
}

.chat-icon-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

/* 헤더 토글 버튼 (줄 번호, 알림) 켜짐 상태 */
.chat-icon-btn.active {
    background: rgba(74, 158, 255, 0.15);
    color: #2b7de9;
}

/* 메시지 머리의 작은 아이콘 버튼 (저장, 크게 보기, 고정) */
.chat-act-btn {
    border: none;
    border-radius: 6px;
    padding: 4px 7px;
    background: rgba(0, 0, 0, 0.05);
    color: #4a5565;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-act-btn:hover {
    background: rgba(74, 158, 255, 0.15);
    color: #2b7de9;
}

.chat-act-btn.active {
    background: rgba(74, 158, 255, 0.18);
    color: #2b7de9;
}

/* 고정 */
.chat-pin-mark {
    display: none;
    color: #e8772e;
    font-size: 11px;
}

.chat-msg.is-pinned .chat-pin-mark {
    display: inline;
}

.chat-msg.is-pinned {
    border-color: rgba(232, 119, 46, 0.45);
}

.chat-pinned {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 14px 8px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: #fff8f1;
}

.chat-pinned-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    font-size: 13px;
    color: #1a1a1a;
    cursor: pointer;
}

.chat-pinned-item:hover {
    background: rgba(232, 119, 46, 0.1);
}

.chat-pinned-item > i {
    color: #e8772e;
    width: 14px;
    text-align: center;
}

.chat-pinned-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-msg.flash {
    animation: chatFlash 1.2s ease;
}

@keyframes chatFlash {
    0%, 100% { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06); }
    30% { box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.55); }
}

/* 날짜 구분선 */
.chat-date-sep {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #8792a2;
    font-size: 12px;
}

.chat-date-sep::before,
.chat-date-sep::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(0, 0, 0, 0.1);
}

/* 삭제 되돌리기 */
.chat-msg.is-deleting > :not(.chat-undo-bar) {
    display: none;
}

.chat-msg.is-deleting {
    background: #f7f8fa;
    border-style: dashed;
}

.chat-undo-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #8792a2;
    font-size: 13px;
}

.chat-undo-bar span {
    flex: 1;
}

.chat-undo-bar button {
    border: none;
    border-radius: 6px;
    padding: 5px 12px;
    background: #4a9eff;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

/* 코드 크게 보기 (프로젝터용) */
.chat-code-viewer {
    position: fixed;
    inset: 0;
    z-index: 9700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3vh 3vw;
    background: rgba(0, 0, 0, 0.6);
    outline: none;
}

.chat-code-viewer.hidden {
    display: none;
}

.chat-viewer-box {
    display: flex;
    flex-direction: column;
    width: min(1400px, 100%);
    max-height: 100%;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.chat-viewer-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px 10px 18px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    color: #4a5565;
    font-size: 14px;
}

.chat-viewer-title {
    flex: 1;
    font-weight: 600;
}

.chat-viewer-actions {
    display: flex;
    gap: 6px;
}

.chat-viewer-actions .chat-act-btn,
.chat-viewer-actions .chat-copy-btn {
    padding: 6px 10px;
    font-size: 13px;
}

.chat-viewer-body {
    flex: 1;
    min-height: 0;
    display: flex;
    padding: 14px;
}

.chat-viewer-body .chat-code-wrap {
    flex: 1;
    max-height: calc(100vh - 6vh - 90px);
    font-size: inherit;
}

/* ---------------------------------------------------------------------------
   학생 → 교사 메시지 (교사가 허용한 경우)
   --------------------------------------------------------------------------- */
/* 교사 화면의 학생 메시지: 노란 왼쪽 띠로 교사 메시지와 구분 */
.chat-msg.is-student {
    background: #fffdf5;
    border-left: 3px solid #f0b429;
}

/* 학생 본인이 보낸 메시지 */
.chat-msg.is-mine {
    background: #f3f8ff;
    border-left: 3px solid #4a9eff;
}

.chat-msg.is-blocked {
    opacity: 0.55;
}

.chat-msg-avatar.is-student {
    background: #fff4d6;
    border-color: rgba(240, 180, 41, 0.5);
    color: #b7791f;
}

.chat-msg.is-mine .chat-msg-avatar.is-student {
    background: #e8f1ff;
    border-color: rgba(74, 158, 255, 0.35);
    color: #4a9eff;
}

.chat-msg-name {
    flex: 0 1 auto;
    font-weight: 600;
    color: #3a4352;
    min-width: 2em;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}



.chat-msg-sid {
    flex: 0 0 auto;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 11px;
    color: #a0a9b6;
}

/* 교사가 전체에 공유한 학생 질문 */
.chat-msg-label {
    flex: 0 0 auto;
    padding: 1px 7px;
    border-radius: 10px;
    background: #fff4d6;
    color: #b7791f;
    font-size: 11px;
}

.chat-block-btn.active {
    background: rgba(229, 72, 77, 0.12);
    color: #e5484d;
}

/* 헤더의 "학생 메시지 허용" 토글: 켜져 있으면 초록색 */
.chat-allow-btn.active {
    background: rgba(47, 179, 109, 0.15);
    color: #1f9d5c;
}

.chat-student-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 12px;
    color: #4a5565;
}

.chat-student-bar > i {
    color: #4a9eff;
}

.chat-sendas.missing {
    color: #c05621;
}

.chat-nick-btn {
    border: none;
    border-radius: 6px;
    padding: 3px 8px;
    background: rgba(0, 0, 0, 0.05);
    color: #2b7de9;
    font-size: 12px;
    cursor: pointer;
}

.chat-nick-btn:hover {
    background: rgba(74, 158, 255, 0.15);
}

.chat-private-note {
    margin-left: auto;
    color: #8792a2;
    font-size: 11px;
}

.chat-input:disabled {
    background: #f5f6f8;
    cursor: not-allowed;
}

/* 이전 메시지 더 보기 */
.chat-more-btn {
    align-self: center;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    padding: 5px 14px;
    background: #fff;
    color: #4a5565;
    font-size: 12px;
    cursor: pointer;
}

.chat-more-btn:hover {
    color: #2b7de9;
}

.chat-more-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

@media (max-width: 600px) {
    .chat-panel {
        top: 0;
        width: 100vw !important;
        max-width: 100vw;
        height: 100vh;
        border-radius: 0;
    }
}

/* 채팅·메모 패널이 열려 있으면 칠판의 오른쪽 페이지 넘김 버튼(z-index 9990)이 패널 위로 비치지 않게 숨긴다
   (페이지 넘김은 키보드 ← → 와 왼쪽 화살표로 계속 가능) */
body:has(#chatPanel:not(.hidden)) #fullscreenNavRight,
body:has(#memoPanel:not(.hidden)) #fullscreenNavRight {
    display: none !important;
}
