#panel-left.collapsed,
#panel-mid.collapsed {
    display: flex;
    position: relative;
}
#panel-left.collapsed > :not(.panel-collapse-btn),
#panel-mid.collapsed > :not(.panel-collapse-btn) {
    display: none !important;
}
.conversations-header .btn.btn-primary {
    white-space: nowrap;
    line-height: 1.2;
    padding-top: 8px;
    padding-bottom: 8px;
}
/* ===============================================
   Messages Root & Panel Layout
   =============================================== */

.starborn-messages-root {
    display: flex;
    width: 100vw;
    height: calc(100vh - 60px);
    margin-top: 60px;
    position: relative;
    overflow: hidden;
}

.starborn-panel {
    background: rgba(10, 10, 20, 0.95);
    border-right: 1px solid rgba(224, 179, 255, 0.2);
    position: relative;
    transition: all 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.starborn-panel-left {
    width: 280px;
    min-width: 280px;
    display: flex;
    flex-direction: column;
}

.starborn-panel-mid {
    width: 350px;
    min-width: 350px;
}

.starborn-panel-right {
    flex: 1;
    border-right: none;
}

.starborn-panel.collapsed {
    width: 0;
    min-width: 0;
    padding: 0;
    border: none;
}

/* ===============================================
   Messages Container
   =============================================== */

.messages-container {
    /* --- END FLUSH FULL-VIEWPORT PANELS --- */
    padding: 0;
    width: 100vw;
    max-width: 100vw;
    min-height: calc(100vh - 60px);
    margin: 0;
    display: flex;
    flex-direction: column;
}

.messages-header {
    margin-bottom: 30px;
}

.messages-header h1 {
    font-size: 36px;
    background: linear-gradient(135deg, #e0b3ff, #ffb3d9, #b3e0ff);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: marbleShift 8s ease infinite;
    margin-bottom: 20px;
}

.character-selector {
    display: flex;
    align-items: center;
    gap: 15px;
}

.character-selector label {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.character-selector select {
    background: rgba(20, 20, 30, 0.8);
    color: #ffffff;
    border: 1px solid rgba(224, 179, 255, 0.3);
    padding: 10px 15px;
    border-radius: 4px;
    font-size: 14px;
    min-width: 300px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.character-selector select:hover {
    border-color: #e0b3ff;
}

.character-selector select:focus {
    outline: none;
    border-color: #ffb3d9;
    box-shadow: 0 0 10px rgba(255, 179, 217, 0.3);
}

/* ===============================================
   Messaging Interface
   =============================================== */

.messaging-interface.hidden {
    display: none;
}

.messages-layout.redesigned-layout {
    display: flex;
    flex-direction: row;
    width: 100vw;
    height: calc(100vh - 60px);
    min-height: 600px;
    gap: 0;
}

/* Character Side Panel */
.character-side-panel {
    background: linear-gradient(135deg, #181828 60%, #22223a 100%);
    border-right: 1.5px solid rgba(224, 179, 255, 0.18);
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    min-width: 260px;
    max-width: 320px;
    height: 100%;
    position: relative;
    left: 0;
    top: 0;
    box-shadow: none;
}
.character-panel-header {
    padding: 18px 16px 10px 16px;
    font-size: 17px;
    font-weight: bold;
    color: #ffb3d9;
    border-bottom: 1px solid rgba(224, 179, 255, 0.2);
    background: rgba(224, 179, 255, 0.05);
    flex-shrink: 0;
}

.panel-collapse-btn {
    background: none;
    border: none;
    color: #ffb3d9;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}
.panel-collapse-btn:hover {
    background: rgba(224, 179, 255, 0.08);
}

#panel-left .panel-collapse-btn {
    position: absolute;
    right: 0;
    top: 75px;
    width: 24px;
    height: 48px;
    background: #181828;
    border-radius: 8px 0 0 8px;
    box-shadow: 2px 0 8px rgba(0,0,0,0.2);
    justify-content: flex-end;
    z-index: 100;
    pointer-events: auto;
    display: flex !important;
    align-items: center;
}

#panel-left.collapsed .panel-collapse-btn {
    right: 0;
    border-radius: 0 8px 8px 0;
}


#panel-left.collapsed {
    min-width: 0 !important;
    width: 0 !important;
    overflow: visible !important;
}

/* Mid panel collapse button as tab */
#panel-mid .panel-collapse-btn {
    position: absolute;
    right: 0;
    top: 75px;
    width: 24px;
    height: 48px;
    background: #181828;
    border-radius: 8px 0 0 8px;
    box-shadow: -2px 0 8px rgba(0,0,0,0.2);
    justify-content: flex-end;
    z-index: 100;
    pointer-events: auto;
    display: flex !important;
    align-items: center;
}
#panel-mid.collapsed {
    min-width: 0 !important;
    width: 0 !important;
    overflow: visible !important;
    position: relative;
}
#panel-mid.collapsed .panel-collapse-btn {
    pointer-events: auto;
    z-index: 100;
    display: flex !important;
}
.character-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}
.character-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    cursor: pointer;
    border-bottom: 1px solid rgba(224, 179, 255, 0.07);
    transition: background 0.2s;
}
.character-item:hover {
    background: rgba(224, 179, 255, 0.08);
}
.character-item.selected {
    background: linear-gradient(90deg, #2a223a 60%, #181828 100%);
    border-left: 6px solid #ffb3d9;
}
.character-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e0b3ff, #ffb3d9, #b3e0ff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    color: #0a0a14;
    box-shadow: 0 2px 8px rgba(224, 179, 255, 0.2);
}
.character-name {
    font-weight: 600;
    color: #fff;
    font-size: 15px;
}
.character-name-small {
    font-weight: 600;
    color: #fff;
    font-size: 12px;
}
.character-code {
    font-size: 13px;
    color: #b3e0ff;
    margin-left: 6px;
}

/* ===============================================
   Conversations Panel
   =============================================== */

.conversations-panel {
    background: linear-gradient(135deg, #181828 60%, #22223a 100%);
    border-right: 1.5px solid rgba(224, 179, 255, 0.18);
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    min-width: 340px;
    max-width: 400px;
    height: 100%;
    position: relative;
    top: 0;
    box-shadow: none;
}

.conversations-header {
    padding: 15px;
    border-bottom: 1px solid rgba(224, 179, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(224, 179, 255, 0.05);
}

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

.conversations-header h3 {
    margin: 0;
    font-size: 18px;
    color: #ffb3d9;
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    padding: 15px;
    border-bottom: 1px solid rgba(0, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
}

.conversation-item:hover {
    background: rgba(224, 179, 255, 0.1);
}

.conversation-item.active {
    background: linear-gradient(90deg, #2a223a 60%, #181828 100%);
    border-left: 6px solid #ffb3d9;
}

.conversation-name {
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.conversation-preview {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background: #ffb3d9;
    color: #0a0a14;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: bold;
}

.no-conversations {
    padding: 30px;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
}

/* ===============================================
   Messages Panel
   =============================================== */

.messages-panel {
    background: linear-gradient(135deg, #22223a 60%, #181828 100%);
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex: 1;
    height: 100%;
    position: relative;
    top: 0;
    box-shadow: none;
    box-shadow: 0 2px 8px rgba(224, 179, 255, 0.08);
}

.no-conversation {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: rgba(255, 255, 255, 0.7);
    font-size: 32px;
    text-align: center;
    font-weight: 600;
    min-height: 300px;
}
.no-conversation.centered {
    display: flex !important;
    align-items: center;
    justify-content: center;
    height: 100%;
}
.conversation-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.conversation-view.hidden {
    display: none;
}

.conversation-header {
    padding: 15px;
    border-bottom: 1px solid rgba(224, 179, 255, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(224, 179, 255, 0.05);
}

.conversation-header h3 {
    margin: 0;
    font-size: 18px;
    color: #ffffff;
}

.messages-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px 48px 32px 48px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    min-height: 0;
}

.no-messages {
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    padding: 24px 48px 24px 48px;
    border-top: 1.5px solid rgba(0, 255, 255, 0.18);
    display: flex;
    gap: 18px;
    background: linear-gradient(90deg, #181828 60%, #22223a 100%);
    border-radius: 0 0 0 0;
}

.message {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    animation: messageSlide 0.3s ease;
}

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

.message-own {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(224, 179, 255, 0.2), rgba(179, 224, 255, 0.2));
    border: 1px solid rgba(255, 179, 217, 0.3);
}

.message-other {
    align-self: flex-start;
    background: rgba(30, 30, 45, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 15px;
}

.message-sender {
    font-weight: 600;
    color: #ffb3d9;
    font-size: 13px;
}

.message-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
}

.message-image {
    margin: 8px 0;
}

.message-image img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    border: 1px solid rgba(224, 179, 255, 0.2);
}

.message-text {
    color: #ffffff;
    word-wrap: break-word;
    line-height: 1.5;
}

.message-text strong {
    font-weight: 700;
}

.message-text em {
    font-style: italic;
}

.message-text u {
    text-decoration: underline;
}

.message-text del {
    text-decoration: line-through;
    opacity: 0.7;
}

.message-text code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    

#panel-mid .panel-collapse-btn {
    position: fixed;
    left: 280px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 56px;
    background: #181828;
    border-radius: 8px 0 0 8px;
    box-shadow: -2px 0 8px rgba(0,0,0,0.2);
    justify-content: center;
    align-items: center;
    z-index: 200;
}
}
#panel-left.collapsed .panel-collapse-btn {
    left: 0;
}
}
#panel-mid.collapsed .panel-collapse-btn {
    left: 0;
}
}

.btn-icon {
    background: rgba(224, 179, 255, 0.1);
    border: 1px solid rgba(255, 179, 217, 0.3);
    color: #ffb3d9;
    width: 40px;
    height: 40px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: rgba(0, 255, 255, 0.2);
    border-color: #ffb3d9;
}

.input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.image-preview {
    position: relative;
    max-width: 200px;
}

.image-preview.hidden {
    display: none;
}

.image-preview img {
    width: 100%;
    max-height: 100px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid rgba(255, 179, 217, 0.3);
}

.remove-image-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(238, 90, 111, 0.9);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: all 0.3s ease;
}

.remove-image-btn:hover {
    background: #ee5a6f;
    box-shadow: 0 0 10px rgba(238, 90, 111, 0.5);
}

.message-input-area textarea {
    flex: 1;
    background: rgba(30, 30, 45, 0.8);
    color: #ffffff;
    border: 1px solid rgba(224, 179, 255, 0.2);
    border-radius: 4px;
    padding: 10px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    min-height: 60px;
}

.message-input-area textarea:focus {
    outline: none;
    border-color: #ffb3d9;
    box-shadow: 0 0 10px rgba(255, 179, 217, 0.3);
}

/* ===============================================
   Buttons
   =============================================== */

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #ffb3d9, #e0b3ff);
    color: #0a0a14;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #e0b3ff, #ffb3d9);
    box-shadow: 0 0 15px rgba(255, 179, 217, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
    color: white;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #ee5a6f, #ff6b6b);
    box-shadow: 0 0 15px rgba(238, 90, 111, 0.5);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* ===============================================
   Modal
   =============================================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: rgba(20, 20, 30, 0.95);
    border: 1px solid rgba(255, 179, 217, 0.3);
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid rgba(224, 179, 255, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    background: linear-gradient(135deg, #e0b3ff, #ffb3d9, #b3e0ff);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: marbleShift 8s ease infinite;
    font-size: 24px;
}

.modal-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
    transition: all 0.3s ease;
}

.modal-close:hover {
    color: #ffb3d9;
    transform: rotate(90deg);
}

.modal-body {
    padding: 20px;
}

/* ===============================================
   Form Styles
   =============================================== */

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
}

.form-group input[type="text"],
.form-group input[type="checkbox"] {
    margin-right: 8px;
}

.form-group input[type="text"] {
    width: 100%;
    background: rgba(30, 30, 45, 0.8);
    color: #ffffff;
    border: 1px solid rgba(224, 179, 255, 0.2);
    padding: 10px;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: #ffb3d9;
    box-shadow: 0 0 10px rgba(255, 179, 217, 0.3);
}

.participants-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid rgba(224, 179, 255, 0.2);
    border-radius: 4px;
    padding: 15px;
    background: rgba(30, 30, 45, 0.5);
}

.participant-checkbox {
    display: block;
    padding: 8px;
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 4px;
}

.participant-checkbox:hover {
    background: rgba(224, 179, 255, 0.1);
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.button-group .btn {
    flex: 1;
}

/* ===============================================
   Notification
   =============================================== */

/* ===============================================
   Loading State
   =============================================== */

.loading {
    text-align: center;
    padding: 20px;
    color: rgba(255, 255, 255, 0.6);
}

/* ===============================================
   Scrollbar Styles
   =============================================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(10, 10, 20, 0.5);
}

::-webkit-scrollbar-thumb {
    background: rgba(224, 179, 255, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(224, 179, 255, 0.5);
}

/* ===============================================
   Responsive Design
   =============================================== */

@media (max-width: 968px) {
    .messages-layout.redesigned-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    .character-side-panel {
        display: none;
    }
    .conversations-panel {
        height: 300px;
    }
    .message {
        max-width: 85%;
    }
}
