/* ===== 기본/리셋 ===== */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f5f7;
    font-family: -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
    color: #222;
}

/* ===== 카드형 페이지 (로그인/회원가입/마이페이지) ===== */

.card {
    position: relative;
    width: 100%;
    max-width: 360px;
    background: #fff;
    padding: 32px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.corner-toggle {
    position: absolute;
    top: 16px;
    right: 16px;
}

.card h1 {
    font-size: 20px;
    margin: 0 0 24px;
    text-align: center;
}

/* ===== 아바타/프로필 사진 (없으면 닉네임 첫 글자 원형으로 대체) ===== */

.avatar {
    border-radius: 50%;
    background: #d9dbe0;
    color: #555;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

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

.avatar-small {
    width: 32px;
    height: 32px;
    font-size: 13px;
}

.avatar-large {
    width: 64px;
    height: 64px;
    font-size: 24px;
}

.profile-image-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
}

.profile-image-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.profile-image-form input[type="file"] {
    font-size: 12px;
}

/* ===== 폼 공통 (로그인/회원가입/마이페이지/방 만들기 등) ===== */

.field {
    margin-bottom: 14px;
}

.field label {
    display: block;
    font-size: 13px;
    color: #555;
    margin-bottom: 6px;
}

.field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d9dbe0;
    border-radius: 6px;
    font-size: 14px;
}

.field input:focus {
    outline: none;
    border-color: #4f6ef7;
}

.btn {
    display: inline-block;
    width: 100%;
    padding: 11px;
    border: none;
    border-radius: 6px;
    background: #4f6ef7;
    color: #fff;
    font-size: 15px;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    margin-top: 6px;
    box-sizing: border-box;
}

.btn:hover {
    background: #3d5be0;
}

.btn-secondary {
    background: #eceef4;
    color: #333;
}

.btn-secondary:hover {
    background: #dee1eb;
}

.error {
    background: #fdecea;
    color: #c0392b;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 14px;
}

.success {
    background: #eafaf0;
    color: #1e874b;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 14px;
}

.card hr {
    border: none;
    border-top: 1px solid #eceef4;
    margin: 24px 0;
}

.link-row {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: #666;
}

.link-row a {
    color: #4f6ef7;
    text-decoration: none;
}

.welcome {
    text-align: center;
}

.welcome p {
    color: #555;
    margin-bottom: 24px;
}

/* ===== 채팅방 목록 / 친구 목록 페이지 ===== */

.page {
    width: 100%;
    max-width: 720px;
    background: #fff;
    padding: 28px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: 20px;
    margin: 0;
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-small {
    width: auto;
    padding: 8px 14px;
    font-size: 13px;
    margin-top: 0;
}

#new-group-btn {
    margin-bottom: 16px;
}

.create-form {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.create-form input[type=text] {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #d9dbe0;
    border-radius: 6px;
    font-size: 14px;
}

.create-form select {
    padding: 10px;
    border: 1px solid #d9dbe0;
    border-radius: 6px;
    font-size: 14px;
}

.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 18px;
    border-bottom: 1px solid #eceef4;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    font-size: 14px;
    color: #999;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tab-btn.active {
    color: #4f6ef7;
    border-bottom-color: #4f6ef7;
    font-weight: 600;
}

/* ===== 그룹 채팅 만들기 / 초대 / 참여자 / 이름변경 등 채팅방 관리 패널 공통 ===== */

.group-form {
    margin: 0 0 16px;
    padding: 14px;
    border: 1px solid #eceef4;
    border-radius: 8px;
}

.group-form input[type=text] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d9dbe0;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 10px;
}

.friend-checklist {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 8px;
}

.friend-checklist label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    padding: 4px 0;
}

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

.form-actions .btn {
    width: auto;
    flex: 1;
    margin-top: 0;
}

/* ===== 친구 목록 / 참여자 목록 / 검색결과 등 리스트 행 공통 ===== */

.friend-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid #eceef4;
    border-radius: 8px;
}

.search-result-item {
    cursor: pointer;
}

.search-result-item:hover {
    background: #f8f9fc;
}

.friend-item .nickname {
    font-weight: 500;
}

.member-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ===== 사진/파일 모아보기 ===== */

.media-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.media-grid img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    display: block;
}

.media-file-item {
    cursor: pointer;
}

.media-file-name {
    font-weight: 500;
}

.media-file-meta {
    font-size: 12px;
    color: #888;
    margin-left: 6px;
}

.creator-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 4px;
    background: #fff3cd;
    color: #a67c00;
    font-size: 11px;
    font-weight: 600;
}

.friend-item .username {
    font-size: 12px;
    color: #888;
    margin-left: 6px;
}

.friend-item .friend-actions {
    display: flex;
    gap: 6px;
}

.room-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* 방 목록을 1:1/그룹으로 나누는 섹션 제목 (클릭 불가능한 라벨) */
.room-section-header {
    font-size: 13px;
    font-weight: 600;
    color: #888;
    padding: 8px 2px 0;
}

.room-section-header:first-child {
    padding-top: 0;
}

/* ===== 채팅방 목록 아이템 (즐겨찾기 별, 안읽음 뱃지 포함) ===== */

.room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid #eceef4;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
}

.room-item:hover {
    background: #f8f9fc;
}

.room-item.pinned {
    background: #fff9ec;
}

.room-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.pin-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    padding: 0;
    color: #ccc;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1;
}

.pin-btn:hover {
    color: #999;
}

.pin-btn.pinned {
    color: #f5a623;
}

.pin-btn.pinned svg {
    fill: currentColor;
}

.room-item .room-type {
    font-size: 12px;
    color: #888;
    margin-left: 8px;
}

.room-item .member-count {
    font-size: 13px;
    color: #4f6ef7;
    white-space: nowrap;
}

.room-item-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.unread-badge {
    display: none;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #ff4d4f;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
}

.empty {
    color: #999;
    text-align: center;
    padding: 24px 0;
}

/* ===== 채팅방 화면 레이아웃 ===== */

.chat-page {
    width: 100%;
    max-width: 560px;
    height: 82vh;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.chat-header {
    padding: 14px 18px;
    border-bottom: 1px solid #eceef4;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header h1 {
    font-size: 16px;
    margin: 0;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.menu-wrapper {
    position: relative;
}

.menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    background: #fff;
    border: 1px solid #eceef4;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    min-width: 140px;
    overflow: hidden;
    z-index: 10;
}

.menu-item {
    border: none;
    background: none;
    text-align: left;
    padding: 10px 14px;
    font-size: 14px;
    cursor: pointer;
    color: #222;
    white-space: nowrap;
}

.menu-item:hover {
    background: #f4f5f9;
}

.menu-item-danger {
    color: #ff4d4f;
}

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

#invite-form,
#members-panel,
#search-panel,
#media-panel {
    flex-shrink: 0;
    margin: 0 16px;
    margin-top: 12px;
    max-height: 260px;
    overflow-y: auto;
}

#search-panel .create-form {
    margin-bottom: 10px;
}

#members-list,
#search-results {
    margin-bottom: 8px;
}

.search-result-sender {
    font-weight: 500;
    margin-right: 6px;
}

.search-result-time {
    font-size: 12px;
    color: #999;
}

.icon-btn {
    border: none;
    background: none;
    font-size: 18px;
    line-height: 1;
    color: #333;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
}

.icon-btn:hover {
    background: #f0f1f5;
}

/* ===== 메시지 목록 영역 (스크롤, 더보기, 최신으로 이동, 안읽음 구분선) ===== */

.chat-messages-wrapper {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.jump-to-latest {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    width: auto;
}

.msg-block.highlight .bubble {
    animation: highlight-flash 1.6s ease;
}

@keyframes highlight-flash {
    0%, 15% {
        box-shadow: 0 0 0 3px rgba(255, 196, 0, 0.9);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 196, 0, 0);
    }
}

.unread-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
    color: #ff4d4f;
    font-size: 12px;
    font-weight: 500;
    align-self: stretch;
}

.unread-divider::before,
.unread-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #ffd6d6;
}

/* ===== 메시지 말풍선 (텍스트/이미지/파일/답장인용/삭제됨) ===== */

.msg.system {
    align-self: center;
    background: transparent;
    color: #999;
    font-size: 12px;
    max-width: 100%;
    word-break: break-word;
}

.msg-block {
    display: flex;
    flex-direction: column;
    max-width: 75%;
}

.msg-block.mine {
    align-self: flex-end;
    align-items: flex-end;
}

.msg-block:not(.mine) {
    align-self: flex-start;
    align-items: flex-start;
}

.sender-name {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.msg-with-avatar {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.msg-avatar {
    margin-top: 2px;
}

.msg-content-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.msg-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.bubble {
    padding: 8px 12px;
    border-radius: 4px 14px 14px 14px;
    background: #f0f1f5;
    color: #222;
    font-size: 14px;
    word-break: break-word;
}

.msg-block.mine .bubble {
    background: #4f6ef7;
    color: #fff;
    border-radius: 14px 4px 14px 14px;
}

.bubble.bubble-image,
.msg-block.mine .bubble.bubble-image {
    padding: 0;
    background: transparent;
}

.bubble.bubble-file {
    padding: 0;
}

.bubble-image img {
    display: block;
    max-width: 220px;
    max-height: 220px;
    border-radius: 12px;
    cursor: pointer;
    object-fit: cover;
}

.file-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    text-decoration: none;
    color: inherit;
    max-width: 220px;
}

.file-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #4f6ef7;
}

.msg-block.mine .file-icon {
    color: #fff;
}

.file-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.file-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 11px;
    opacity: 0.75;
}

.bubble.deleted {
    font-style: italic;
    color: #999;
}

.msg-block.mine .bubble.deleted {
    background: #eceef4;
    color: #888;
}

.reply-quote {
    border-left: 3px solid rgba(0, 0, 0, 0.15);
    padding: 4px 8px;
    margin-bottom: 6px;
    font-size: 12px;
    opacity: 0.85;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.05);
    cursor: pointer;
}

.reply-quote:hover {
    opacity: 1;
}

.msg-block.mine .reply-quote {
    border-left-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.15);
}

.reply-quote .reply-quote-sender {
    font-weight: 600;
    margin-right: 4px;
}

.meta-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.msg-block.mine .meta-stack {
    align-items: flex-end;
}

.msg-block:not(.mine) .meta-stack {
    align-items: flex-start;
}

.time {
    font-size: 11px;
    color: #999;
    white-space: nowrap;
}

.unread-count {
    display: none;
    font-size: 11px;
    font-weight: 700;
    color: #ff4d4f;
    white-space: nowrap;
}

.time-actions-row {
    display: flex;
    align-items: center;
    gap: 5px;
}

.msg-actions {
    display: none;
    gap: 4px;
}

.meta-stack:hover .time {
    display: none;
}

.meta-stack:hover .msg-actions {
    display: flex;
}

.msg-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    padding: 0;
    color: #aaa;
    cursor: pointer;
    line-height: 1;
}

.msg-action-btn:hover {
    color: #666;
}

/* ===== 이모지 반응 (알약 배지 + 선택 피커) ===== */

.reactions-row {
    display: none;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.reaction-pill {
    border: 1px solid #e0e2e8;
    background: #fff;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    line-height: 1.4;
    cursor: pointer;
}

.reaction-pill:hover {
    background: #f8f9fc;
}

.reaction-pill.mine {
    border-color: #4f6ef7;
    background: #eef1ff;
    color: #4f6ef7;
}

.reaction-picker {
    display: none;
    gap: 4px;
    margin-top: 4px;
    padding: 4px 6px;
    border: 1px solid #eceef4;
    border-radius: 20px;
    background: #fff;
    width: fit-content;
}

.reaction-picker-btn {
    border: none;
    background: none;
    font-size: 16px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 50%;
    cursor: pointer;
}

.reaction-picker-btn:hover {
    background: #f0f1f5;
}

.reaction-picker-btn.active {
    background: #eef1ff;
    box-shadow: inset 0 0 0 1.5px #4f6ef7;
}

/* ===== 입력 중 표시 ===== */

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 16px;
    flex-shrink: 0;
}

.typing-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #d9dbe0;
    color: #555;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

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

.typing-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.typing-name {
    font-size: 11px;
    color: #888;
}

.typing-bubble {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 8px 12px;
    background: #f0f1f5;
    border-radius: 4px 14px 14px 14px;
    width: fit-content;
}

.typing-bubble .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #999;
    animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-bubble .dot:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-bubble .dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* ===== 답장 미리보기 + 메시지 입력창(첨부 버튼 포함) ===== */

.reply-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 16px;
    background: #f4f5f9;
    border-top: 1px solid #eceef4;
    flex-shrink: 0;
}

.reply-preview-body {
    min-width: 0;
}

.reply-preview-sender {
    font-size: 12px;
    font-weight: 600;
    color: #4f6ef7;
}

.reply-preview-content {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-input {
    display: flex;
    gap: 8px;
    padding: 14px;
    border-top: 1px solid #eceef4;
    flex-shrink: 0;
}

.attach-wrapper {
    position: relative;
}

.attach-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 6px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #eceef4;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    white-space: nowrap;
}

.attach-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
    background: none;
    padding: 10px 14px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    text-align: left;
}

.attach-menu-item:hover {
    background: #f8f9fc;
}

.chat-input input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #d9dbe0;
    border-radius: 6px;
    font-size: 14px;
}

.chat-input input:disabled,
.chat-input button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.load-more {
    align-self: center;
    margin-bottom: 8px;
}

.field-error {
    color: #c0392b;
    font-size: 12px;
    margin: -12px 0 12px;
    min-height: 14px;
}

/* ===== 이미지 확대 모달 (클릭 시 새 탭 대신 화면 안에서 크게 보기) ===== */

.image-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 24px;
}

.image-modal img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 4px;
    object-fit: contain;
}

.image-modal-close {
    position: fixed;
    top: 20px;
    right: 24px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 18px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-modal-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ===== 반응형 (모바일에서는 카드형 대신 화면을 꽉 채운다) =====
   PC(뷰포트 640px 초과)는 지금처럼 가운데 정렬된 카드형 레이아웃 그대로 두고,
   그보다 좁은 화면(휴대폰)에서는 여백/둥근 모서리/그림자를 없애고 전체화면으로 바꾼다. */
@media (max-width: 640px) {
    body {
        align-items: stretch;
        justify-content: stretch;
    }

    .card,
    .page {
        max-width: none;
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        border-radius: 0;
        box-shadow: none;
    }

    .chat-page {
        max-width: none;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        box-shadow: none;
    }

    /* 말풍선이 화면 폭 대비 너무 좁게 잡히지 않도록 살짝 넓혀준다 */
    .msg-block {
        max-width: 85%;
    }
}

/* ===== 다크모드 =====
   기존 라이트 모드 규칙은 그대로 두고, html[data-theme="dark"] 아래에서 필요한
   색상만 덮어쓰는 방식 (변수 전환이 아님 — 기존 규칙을 건드리지 않아 회귀 위험이 적음). */

/* 폼 컨트롤(체크박스 등)·스크롤바도 브라우저가 알아서 다크 스타일로 그려줌 */
html[data-theme="dark"] {
    color-scheme: dark;
}

/* 페이지 전체 배경/기본 글자색 */
html[data-theme="dark"] body {
    background: #16171b;
    color: #e6e6ea;
}

/* 카드형 페이지·채팅창·드롭다운 메뉴류의 배경 (원래 흰색이던 것들) */
html[data-theme="dark"] .card,
html[data-theme="dark"] .page,
html[data-theme="dark"] .chat-page,
html[data-theme="dark"] .menu-dropdown,
html[data-theme="dark"] .attach-menu,
html[data-theme="dark"] .reaction-picker {
    background: #1f2024;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

/* 제목/메뉴 항목/파일명처럼 진한 색이어야 하는 주요 글자 */
html[data-theme="dark"] .card h1,
html[data-theme="dark"] .page-header h1,
html[data-theme="dark"] .chat-header h1,
html[data-theme="dark"] .menu-item,
html[data-theme="dark"] .attach-menu-item,
html[data-theme="dark"] .friend-item .nickname,
html[data-theme="dark"] .file-name,
html[data-theme="dark"] .media-file-name {
    color: #e6e6ea;
}

/* 헤더의 아이콘 버튼(←, ☰, + 등) 색 */
html[data-theme="dark"] .icon-btn {
    color: #d5d5da;
}

/* 받은 메시지 말풍선 + 타이핑 중 말풍선 배경 */
html[data-theme="dark"] .bubble,
html[data-theme="dark"] .typing-bubble {
    background: #2a2b30;
    color: #e6e6ea;
}

/* 내가 보낸, 삭제된 메시지의 말풍선 (일반 mine 말풍선은 파란색 그대로 유지) */
html[data-theme="dark"] .msg-block.mine .bubble.deleted {
    background: #33343a;
    color: #9a9aa2;
}

/* 시간/보조 설명 등 톤 낮춘 회색 텍스트들 전부 한 번에 */
html[data-theme="dark"] .bubble.deleted,
html[data-theme="dark"] .msg.system,
html[data-theme="dark"] .empty,
html[data-theme="dark"] .time,
html[data-theme="dark"] .typing-name,
html[data-theme="dark"] .search-result-time,
html[data-theme="dark"] .friend-item .username,
html[data-theme="dark"] .room-item .room-type,
html[data-theme="dark"] .room-section-header,
html[data-theme="dark"] .media-file-meta,
html[data-theme="dark"] .field label,
html[data-theme="dark"] .link-row,
html[data-theme="dark"] .welcome p,
html[data-theme="dark"] .reply-preview-content {
    color: #9a9aa2;
}

/* 그룹채팅 발신자 닉네임 */
html[data-theme="dark"] .sender-name {
    color: #b4b4bc;
}

/* 원래 옅은 회색(#eceef4) 테두리를 쓰던 요소들의 테두리색 */
html[data-theme="dark"] .card hr,
html[data-theme="dark"] .group-form,
html[data-theme="dark"] .friend-item,
html[data-theme="dark"] .room-item,
html[data-theme="dark"] .chat-header,
html[data-theme="dark"] .menu-dropdown,
html[data-theme="dark"] .attach-menu,
html[data-theme="dark"] .reaction-picker,
html[data-theme="dark"] .chat-input,
html[data-theme="dark"] .reply-preview,
html[data-theme="dark"] .tabs {
    border-color: #33343a;
}

/* 로그인/검색/메시지 입력창 등 텍스트 입력 필드 (배경+테두리+글자색) */
html[data-theme="dark"] .field input,
html[data-theme="dark"] .create-form input[type=text],
html[data-theme="dark"] .create-form select,
html[data-theme="dark"] .group-form input[type=text],
html[data-theme="dark"] .chat-input input {
    background: #1a1b1f;
    border-color: #3a3b42;
    color: #e6e6ea;
}

/* 목록/버튼류 마우스 오버 시 배경 (라이트모드의 옅은 회색 hover 대응) */
html[data-theme="dark"] .search-result-item:hover,
html[data-theme="dark"] .room-item:hover,
html[data-theme="dark"] .icon-btn:hover,
html[data-theme="dark"] .menu-item:hover,
html[data-theme="dark"] .attach-menu-item:hover,
html[data-theme="dark"] .reaction-picker-btn:hover {
    background: #2a2b30;
}

/* 보조 버튼(취소, 닫기 등) 기본 배경 */
html[data-theme="dark"] .btn-secondary {
    background: #2a2b30;
    color: #e6e6ea;
}

/* 보조 버튼 hover */
html[data-theme="dark"] .btn-secondary:hover {
    background: #34353c;
}

/* 에러 메시지 박스 */
html[data-theme="dark"] .error {
    background: #3a2224;
    color: #ff8a80;
}

/* 성공 메시지 박스 */
html[data-theme="dark"] .success {
    background: #1f3327;
    color: #6fcf97;
}

/* 폼 필드 아래 인라인 에러 텍스트 */
html[data-theme="dark"] .field-error {
    color: #ff8a80;
}

/* 참여자 목록의 "방장" 배지 */
html[data-theme="dark"] .creator-badge {
    background: #4a3c14;
    color: #f0c94d;
}

/* 즐겨찾기(고정)한 채팅방 목록 항목의 배경 강조 */
html[data-theme="dark"] .room-item.pinned {
    background: #332c18;
}

/* 이모지 반응 알약(배경/테두리/글자색) */
html[data-theme="dark"] .reaction-pill {
    background: #1f2024;
    border-color: #3a3b42;
    color: #e6e6ea;
}

/* 반응 알약 hover */
html[data-theme="dark"] .reaction-pill:hover {
    background: #2a2b30;
}

/* 내가 남긴 반응 알약 + 반응 선택창에서 이미 고른 이모지 강조 */
html[data-theme="dark"] .reaction-pill.mine,
html[data-theme="dark"] .reaction-picker-btn.active {
    background: #26304f;
}

/* 프로필 사진 없을 때 뜨는 닉네임 첫 글자 원형 + 타이핑 인디케이터 아바타 */
html[data-theme="dark"] .avatar,
html[data-theme="dark"] .typing-avatar {
    background: #3a3b42;
    color: #d5d5da;
}

/* "여기까지 읽었습니다" 구분선 좌우 실선 */
html[data-theme="dark"] .unread-divider::before,
html[data-theme="dark"] .unread-divider::after {
    background: #4a2a2a;
}

/* 답장 인용 블록 (말풍선 안에 뜨는 원본 메시지 미리보기) */
html[data-theme="dark"] .reply-quote {
    background: rgba(255, 255, 255, 0.06);
    border-left-color: rgba(255, 255, 255, 0.2);
}

/* 메시지 입력창 위에 뜨는 답장 대상 미리보기 줄 */
html[data-theme="dark"] .reply-preview {
    background: #1a1b1f;
}

/* 채팅방 목록의 즐겨찾기 별 아이콘 (기본 상태, 색칠된 상태는 그대로 금색 유지) */
html[data-theme="dark"] .pin-btn {
    color: #55565e;
}
