.msg-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: calc(100vh - 42px - 64px);
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}
.msg-layout--single {
    grid-template-columns: 1fr;
}
.msg-sidebar {
    border-right: 1px solid #e5e7eb;
    display: flex; flex-direction: column; overflow: hidden;
}
.msg-sidebar__header {
    height: 57px; padding: 0 16px;
    display: flex; align-items: center;
    border-bottom: 1px solid #e5e7eb; flex-shrink: 0;
}
.msg-sidebar__header h2 { margin: 0; font-size: 18px; }
.msg-conv-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.msg-conv-item {
    display: flex; align-items: center;
    border-bottom: 1px solid #f3f4f6; position: relative;
}
.msg-conv-item--active { background: #eff6ff; }
.msg-conv-item:hover { background: #f9fafb; }
.msg-conv-item--active:hover { background: #dbeafe; }
.msg-conv-link {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; flex: 1; text-decoration: none; color: inherit; min-width: 0;
}
.msg-conv-avatar { width: 42px; height: 42px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.msg-conv-avatar--placeholder {
    width: 42px; height: 42px; border-radius: 10px;
    background: #0B1F33; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 700; flex-shrink: 0;
}
.msg-conv-meta { flex: 1; min-width: 0; }
.msg-conv-name { display: block; font-weight: 600; font-size: 14px; color: #1f2933; }
.msg-conv-preview {
    display: block; font-size: 12px; color: #9ca3af;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.msg-conv-badge {
    background: #0B1F33; color: #fff; border-radius: 10px;
    min-width: 20px; height: 20px; padding: 0 5px;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.msg-conv-delete-form { margin: 0; padding-right: 6px; flex-shrink: 0; }
.msg-conv-delete-btn {
    background: none; border: none; cursor: pointer;
    color: #d1d5db; font-size: 18px; padding: 4px;
}
.msg-conv-delete-btn:hover { color: #dc2626; }
.msg-conv-empty { padding: 16px; color: #9ca3af; font-size: 14px; }

.msg-panel { display: flex; flex-direction: column; overflow: hidden; }
.msg-panel__empty {
    flex: 1; display: flex; align-items: center; justify-content: center;
    color: #9ca3af; font-size: 15px;
}
.msg-panel__header {
    height: 57px; padding: 0 16px;
    display: flex; align-items: center; gap: 10px;
    border-bottom: 1px solid #e5e7eb; flex-shrink: 0;
}
.msg-panel-avatar { width: 36px; height: 36px; border-radius: 9px; object-fit: cover; }
.msg-panel-avatar--placeholder {
    width: 36px; height: 36px; border-radius: 9px;
    background: #0B1F33; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700;
}
.msg-panel-name { font-weight: 600; font-size: 15px; color: #1f2933; text-decoration: none; }
.msg-panel-name:hover { text-decoration: underline; }

.msg-messages {
    flex: 1; overflow-y: auto; padding: 16px;
    display: flex; flex-direction: column; gap: 8px;
}
.msg-row { display: flex; align-items: flex-end; gap: 8px; }
.msg-row--mine { justify-content: flex-end; }
.msg-bubble-avatar { width: 28px; height: 28px; border-radius: 7px; object-fit: cover; flex-shrink: 0; }
.msg-bubble-avatar--placeholder {
    width: 28px; height: 28px; border-radius: 7px;
    background: #e5e7eb; color: #6b7280;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.msg-bubble { max-width: 60%; padding: 8px 12px; border-radius: 16px; }
.msg-row--other .msg-bubble {
    background: #f3f4f6; color: #1f2933;
    border-radius: 4px 16px 16px 16px;
}
.msg-row--mine .msg-bubble {
    background: #0B1F33; color: #fff;
    border-radius: 16px 4px 16px 16px;
}
.msg-bubble__text { margin: 0 0 4px; font-size: 14px; line-height: 1.5; word-break: break-word; }
.msg-bubble__text:last-child { margin-bottom: 0; }
.msg-bubble__img { max-width: 240px; border-radius: 8px; display: block; margin-bottom: 4px; cursor: pointer; }
.msg-bubble__img:hover { opacity: 0.9; }
.msg-bubble__time { font-size: 11px; opacity: 0.6; display: block; text-align: right; margin-top: 2px; }

.msg-form {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 16px; border-top: 1px solid #e5e7eb; flex-shrink: 0;
}
.msg-form__attach { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.msg-form__photo-btn {
    cursor: pointer; color: #6b7280; flex-shrink: 0;
    display: flex; align-items: center; padding: 6px;
    border-radius: 8px; transition: color 0.15s, background 0.15s;
}
.msg-form__photo-btn:hover { color: #0B1F33; background: #eff6ff; }
.msg-form__preview { display: flex; align-items: center; gap: 4px; }
.msg-form__preview[hidden] { display: none; }
.msg-form__preview img { height: 36px; width: 36px; border-radius: 6px; object-fit: cover; }
.msg-form__preview-clear {
    background: none; border: none; cursor: pointer;
    font-size: 15px; color: #9ca3af; padding: 0 2px; line-height: 1;
}
.msg-form__preview-clear:hover { color: #dc2626; }
.msg-form__input {
    flex: 1; padding: 8px 12px; border: 1px solid #d1d5db;
    border-radius: 20px; font-size: 14px; font-family: inherit;
    resize: none; line-height: 1.5; max-height: 120px; overflow-y: auto; outline: none;
}
.msg-form__input:focus { border-color: #0B1F33; box-shadow: 0 0 0 3px rgba(23,90,156,0.1); }
.msg-form__send {
    background: #0B1F33; color: #fff; border: none; cursor: pointer;
    width: 38px; height: 38px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: background 0.15s;
}
.msg-form__send:hover { background: #13477a; }

#msg-lightbox {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.85);
    display: flex; align-items: center; justify-content: center;
    cursor: zoom-out;
}
#msg-lightbox[hidden] { display: none; }
#msg-lightbox-img {
    max-width: 90vw; max-height: 90vh;
    border-radius: 8px; object-fit: contain;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
