body {
	background: var(--chat-bg);
	min-height: 100dvh;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	position: relative;
	margin: 0;
	padding: 0;
	color: var(--chat-text-primary);
	transition: background-color 0.3s ease, color 0.3s ease;
}

.chat-container {
	flex: 1;
	display: flex;
	flex-direction: column;
	position: relative;
	z-index: 1;
	background: var(--chat-bg);
	min-width: 0;
	height: 100%;
	min-height: 0;
	max-height: 100dvh;
	overflow: hidden;
	transition: background-color 0.3s ease;
}

.right-sidebar-header-row {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	padding: 12px 16px;
	border-bottom: 1px solid var(--chat-border);
	background: transparent;
	position: relative;
}

@media (max-width: 1023px) {
	.right-sidebar-header-row {
		justify-content: flex-start !important;
		align-items: flex-start !important;
		padding: 12px 16px !important;
	}

	.right-sidebar-header-row .sidebar-close-btn {
		position: absolute !important;
		top: 12px !important;
		left: 16px !important;
		right: auto !important;
		margin: 0 !important;
		z-index: 10 !important;
	}
}

.conversation-item {
	padding: 12px;
	margin-bottom: 4px;
	border-radius: 12px;
	cursor: pointer;
	transition: background 0.2s ease;
	position: relative;
	display: flex;
	align-items: flex-start;
	gap: 12px;
}

.conversation-item:hover {
	background: var(--chat-hover-bg);
	color: var(--chat-text-primary) !important;
}

.conversation-item.active {
	background: var(--chat-active-bg);
}

.conversation-item-avatar {
	width: 48px;
	height: 48px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
}

.conversation-item-info {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.conversation-item-title {
	font-weight: 500;
	font-size: 15px;
	color: var(--chat-text-primary);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	display: flex;
	align-items: center;
	gap: 8px;
	transition: color 0.3s ease;
}

.conversation-item-time {
	font-size: 12px;
	color: var(--chat-text-muted);
	transition: color 0.3s ease;
}

.conversation-item-actions {
	position: relative;
}

.conversation-action-trigger {
	background: transparent;
	border: none;
	cursor: pointer;
	padding: 4px 8px;
	border-radius: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity 0.2s ease, background 0.2s ease;
}

.conversation-item:hover .conversation-action-trigger {
	opacity: 0.6;
}

.conversation-action-trigger:hover {
	opacity: 1;
	background: var(--chat-hover-bg);
	color: var(--chat-text-primary) !important;
}

.conversation-action-trigger:hover i {
	color: var(--chat-text-primary) !important;
}

.conversation-action-trigger i {
	font-size: 18px;
	color: var(--chat-text-secondary);
	transition: color 0.3s ease;
}

.conversation-action-menu {
	position: fixed;
	background: var(--chat-card-bg);
	border: 1px solid var(--chat-border);
	border-radius: 8px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	padding: 4px 0;
	display: none;
	z-index: 10000;
	min-width: 160px;
	transition: background-color 0.3s ease, border-color 0.3s ease;
}

.conversation-action-menu.show {
	display: block;
}

.conversation-action-menu-item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 16px;
	cursor: pointer;
	border: none;
	background: none;
	width: 100%;
	text-align: left;
	font-size: 14px;
	color: var(--chat-text-primary);
	transition: background 0.2s ease, color 0.3s ease;
}

.conversation-action-menu-item:hover {
	background: var(--chat-hover-bg);
	color: var(--chat-text-primary) !important;
}

.conversation-action-menu-item:hover i {
	color: var(--chat-text-primary) !important;
}

.conversation-action-menu-item i {
	font-size: 16px;
	width: 20px;
	color: var(--chat-text-secondary);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: color 0.3s ease;
}

.conversation-action-menu-item:hover i {
	color: var(--chat-text-primary);
}

.conversation-action-menu-item span {
	flex: 1;
}

.main-content-area {
	flex: 1;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: transparent;
	min-width: 0;
	min-height: 0;
}

.right-sidebar {
	width: 300px;
	min-height: 100dvh;
	height: 100%;
	background: transparent;
	border-left: 1px solid var(--chat-border);
	display: flex;
	flex-direction: column;
	flex-shrink: 0;
	overflow-y: auto;
	overflow-x: hidden;
	z-index: 100;
	position: relative;
	transition: background-color 0.3s ease, border-color 0.3s ease;
	align-self: stretch;
}

.right-sidebar.hidden {
	display: none;
}

.history-panel {
	position: fixed;
	top: 0;
	right: 0;
	width: 800px;
	height: 100dvh;
	background: var(--chat-card-bg);
	border-left: 1px solid var(--chat-border);
	z-index: 10000;
	display: flex;
	flex-direction: column;
	transform: translateX(100%);
	transition: transform 0.3s ease;
	box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
}

.history-panel.show {
	transform: translateX(0);
}

.history-panel-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 20px;
	border-bottom: 1px solid var(--chat-border);
	background: var(--chat-card-bg);
}

.history-panel-header-left {
	display: flex;
	align-items: center;
	flex: 1;
}

.history-panel-title {
	font-size: 18px;
	font-weight: 600;
	color: var(--chat-text-primary);
	margin: 0;
}

.history-panel-header-right {
	display: flex;
	align-items: center;
	gap: 8px;
}

.history-panel-action-btn {
	background: none;
	border: none;
	padding: 6px;
	cursor: pointer;
	color: var(--chat-text-secondary);
	border-radius: 4px;
	transition: all 0.2s ease;
	display: flex;
	align-items: center;
	justify-content: center;
}

.history-panel-action-btn:hover {
	background: var(--chat-hover-bg);
	color: var(--chat-text-primary) !important;
}

.history-panel-content {
	flex: 1;
	overflow-y: auto;
	overflow-x: hidden;
	position: relative;
}

.balance-history-tab {
	padding: 8px 16px;
	border: none;
}

.transaction-item {
	transition: all 0.2s ease;
}

.transaction-item:hover {
	background: var(--chat-hover-bg, #f8f9fa) !important;
	border-color: var(--chat-primary, #007bff) !important;
}

.transaction-detail-icon {
	transition: transform 0.2s ease;
}

.balance-history-tab {
	padding: 8px 16px;
	border: none;
	background: transparent;
	color: var(--chat-text-secondary);
	cursor: pointer;
	border-bottom: 2px solid transparent;
	transition: all 0.2s;
	font-size: 14px;
	font-weight: 500;
}

.balance-history-tab:hover {
	color: var(--chat-text-primary);
}

.balance-history-tab.active {
	color: var(--chat-primary);
	border-bottom-color: var(--chat-primary);
}

.history-loading {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 40px 20px;
	color: var(--chat-text-secondary);
}

.loading-spinner {
	width: 32px;
	height: 32px;
	border: 3px solid var(--chat-border);
	border-top-color: var(--chat-primary);
	border-radius: 50%;
	animation: spin 1s linear infinite;
	margin-bottom: 12px;
}

@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

.history-messages-list {
	padding: 16px 20px;
}

.history-message-item {
	padding: 12px;
	margin-bottom: 12px;
	background: var(--chat-hover-bg);
	border-radius: 8px;
	border: 1px solid var(--chat-border);
	cursor: pointer;
	transition: all 0.2s ease;
}

.history-message-item:hover {
	background: var(--chat-hover-bg);
	border-color: var(--chat-primary);
	color: var(--chat-text-primary) !important;
}

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

.history-message-user-info {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 1;
}

.history-message-avatar {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
}

.history-message-name {
	font-size: 14px;
	font-weight: 500;
	color: var(--chat-text-primary);
}

.history-message-pinned-badge {
	font-size: 12px;
	margin-left: 4px;
}

.history-message-content {
	font-size: 13px;
	color: var(--chat-text-primary);
	line-height: 1.5;
	word-break: break-word;
	margin-bottom: 6px;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.history-message-time {
	font-size: 11px;
	color: var(--chat-text-muted);
}

.history-pagination {
	padding: 16px 20px;
	border-top: 1px solid var(--chat-border);
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 8px;
	background: var(--chat-card-bg);
}

.history-page-btn {
	padding: 6px 12px;
	background: var(--chat-hover-bg);
	border: 1px solid var(--chat-border);
	border-radius: 4px;
	color: var(--chat-text-primary);
	font-size: 13px;
	cursor: pointer;
	transition: all 0.2s ease;
}

.history-page-btn:hover:not(:disabled) {
	background: var(--chat-primary);
	color: white;
	border-color: var(--chat-primary);
}

.history-page-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.history-page-info {
	font-size: 13px;
	color: var(--chat-text-secondary);
	margin: 0 8px;
}

@media (max-width: 1023px) {
	.history-panel {
		width: 100%;
		z-index: 10001;
	}
}

.right-sidebar-header {
	padding: 20px;
	border-bottom: 1px solid var(--chat-border);
	background: transparent;
	transition: background-color 0.3s ease, border-color 0.3s ease;
}

.right-sidebar-title {
	font-size: 16px;
	font-weight: 600;
	color: var(--chat-text-primary);
	margin-bottom: 16px;
	transition: color 0.3s ease;
}

.right-sidebar-content {
	padding: 0;
	flex: 1;
	width: 100%;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	min-height: 100%;
}

.right-sidebar-content > .role-info-card {
	padding: 20px;
	flex: 0 0 auto;
	overflow-y: visible;
	overflow-x: hidden;
	min-height: fit-content;
}

.right-sidebar-content > .sidebar-options {
	flex: 1;
	display: flex;
	flex-direction: column;
	justify-content: center;
	padding: 20px 0;
	min-height: 0;
}

.role-info-card {
	background: transparent;
	border-radius: 12px;
	padding: 20px;
	margin-bottom: 20px;
	width: 100%;
	box-sizing: border-box;
	overflow-x: hidden;
	transition: background-color 0.3s ease;
}

.role-info-avatar {
	width: 80px;
	height: 80px;
	border-radius: 50%;
	object-fit: cover;
	margin-bottom: 16px;
	border: 3px solid #e0e0e0;
	flex-shrink: 0;
}

.role-description {
	font-size: 13px;
	color: var(--chat-text-secondary, #666);
	line-height: 1.5;
	margin-bottom: 20px;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	text-overflow: ellipsis;
	word-break: break-word;
}
        
        [data-theme="dark"] .role-description,
        [data-theme="dark-blue"] .role-description {
	color: #d0d0d0;
}

.role-action-btn {
	flex: 1;
	min-width: 0;
	padding: 8px 12px;
	border: none;
	border-radius: 20px;
	background: rgba(0, 0, 0, 0.05);
	color: var(--chat-text-secondary, #666);
	font-size: 12px;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
	cursor: pointer;
	transition: all 0.2s ease;
	font-weight: 500;
}

.role-action-btn i {
	font-size: 14px;
	line-height: 1;
}

.role-action-count {
	font-size: 12px;
	font-weight: 500;
	margin-left: 2px;
}

.role-action-btn:hover {
	background: rgba(0, 0, 0, 0.1);
	color: var(--chat-text-primary) !important;
	transform: translateY(-1px);
}

html[data-theme="light"] .role-action-btn:hover,
        html[data-theme="light-blue"] .role-action-btn:hover {
	background: rgba(0, 0, 0, 0.15);
	color: #ffffff !important;
}

html[data-theme="light"] .role-action-btn:hover i,
        html[data-theme="light-blue"] .role-action-btn:hover i,
        html[data-theme="light"] .role-action-btn:hover .bi-bookmark-fill,
        html[data-theme="light-blue"] .role-action-btn:hover .bi-bookmark-fill {
	color: #ffffff !important;
}

.role-action-btn:active {
	transform: translateY(0);
}
        

        [data-theme="dark"] .role-action-btn,
        [data-theme="dark-blue"] .role-action-btn {
	background: rgba(255, 255, 255, 0.08);
	color: var(--chat-text-secondary, #b0b0b0);
}
        
        [data-theme="dark"] .role-action-btn:hover,
        [data-theme="dark-blue"] .role-action-btn:hover {
	background: rgba(255, 255, 255, 0.12);
	color: var(--chat-text-primary) !important;
}

.role-action-btn.active {
	background: rgba(0, 123, 255, 0.15);
	color: #007bff;
}
        
        [data-theme="dark"] .role-action-btn.active,
        [data-theme="dark-blue"] .role-action-btn.active {
	background: rgba(0, 123, 255, 0.2);
	color: #4da3ff;
}

#favoriteRoleBtn.active {
	background: rgba(255, 193, 7, 0.15);
	color: #ffc107;
}
        
        [data-theme="dark"] #favoriteRoleBtn.active,
        [data-theme="dark-blue"] #favoriteRoleBtn.active {
	background: rgba(255, 193, 7, 0.2);
	color: #ffd54f;
}

.role-stats-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 13px;
	padding: 6px 0;
}

.role-stats-label {
	color: #999;
	display: flex;
	align-items: center;
	gap: 6px;
}

.role-stats-value {
	color: #1a1a1a;
	font-weight: 500;
}

.role-info-name {
	font-size: 20px;
	font-weight: 600;
	color: var(--chat-text-primary);
	margin-bottom: 8px;
	transition: color 0.3s ease;
}

.role-info-header-clickable {
	display: flex;
	gap: 12px;
	align-items: center;
	cursor: pointer;
	padding: 8px;
	margin: -8px -8px 8px -8px;
	border-radius: 8px;
	transition: background-color 0.2s ease;
	user-select: none;
}

.role-info-header-clickable:hover {
	background-color: var(--chat-hover-bg);
	color: var(--chat-text-primary) !important;
}

.role-info-header-clickable:active {
	background-color: var(--chat-active-bg, rgba(0, 123, 255, 0.1));
}

.role-info-header-clickable .bi-chevron-right {
	font-size: 18px;
	color: var(--chat-text-secondary);
	flex-shrink: 0;
	margin-left: auto;
	transition: color 0.2s ease, transform 0.2s ease;
}

.role-info-header-clickable:hover .bi-chevron-right {
	color: var(--chat-text-primary);
	transform: translateX(2px);
}

.role-info-description {
	font-size: 14px;
	color: var(--chat-text-secondary);
	line-height: 1.6;
	margin-bottom: 16px;
	transition: color 0.3s ease;
}

.role-info-meta {
	display: flex;
	gap: 16px;
	padding-top: 16px;
	border-top: 1px solid var(--chat-border);
	font-size: 13px;
	color: var(--chat-text-muted);
	transition: color 0.3s ease, border-color 0.3s ease;
}

.role-info-meta-item {
	display: flex;
	align-items: center;
	gap: 6px;
}

.sidebar-options {
	list-style: none;
	padding: 0;
	margin: 0;
}

.sidebar-option-item {
	padding: 12px 16px;
	border-radius: 8px;
	cursor: pointer;
	transition: background 0.2s ease;
	display: flex;
	align-items: center;
	justify-content: space-between;
	color: var(--chat-text-primary);
	font-size: 14px;
}

.sidebar-option-item:hover {
	background: var(--chat-hover-bg);
	color: var(--chat-text-primary) !important;
}

.sidebar-option-item:hover i {
	color: var(--chat-text-secondary) !important;
}

.sidebar-option-item i {
	margin-right: 12px;
	width: 20px;
	color: var(--chat-text-secondary);
}

.sidebar-option-item .option-arrow {
	color: var(--chat-text-muted);
	font-size: 12px;
	transition: transform 0.2s ease;
}

.background-toggle-switch {
	position: relative;
	display: inline-block;
	width: 44px;
	height: 24px;
	margin-left: auto;
	cursor: pointer;
	flex-shrink: 0;
}

.background-toggle-switch input {
	opacity: 0;
	width: 0;
	height: 0;
}

.toggle-slider {
	position: absolute;
	cursor: pointer;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: var(--chat-border, #ccc);
	transition: 0.3s;
	border-radius: 24px;
}

.toggle-slider:before {
	position: absolute;
	content: "";
	height: 18px;
	width: 18px;
	left: 3px;
	bottom: 3px;
	background-color: white;
	transition: 0.3s;
	border-radius: 50%;
}

.background-toggle-switch input:checked + .toggle-slider {
	background-color: var(--chat-primary, #007bff);
}

.background-toggle-switch input:checked + .toggle-slider:before {
	transform: translateX(20px);
}

.sidebar-option-submenu {
	list-style: none;
	padding: 0;
	margin: 0;
	background: var(--chat-hover-bg);
	border-top: 1px solid var(--chat-border);
	max-height: 400px;
	overflow-y: auto;
	transition: background-color 0.3s ease, border-color 0.3s ease;
}

.role-info-card [style*="color: #999"],
        .role-info-card [style*="color: #666"],
        .role-info-card [style*="color: #1a1a1a"],
        .role-info-card [style*="color: #333"] {
	color: var(--chat-text-muted) !important;
}

.role-info-card [style*="color: #1a1a1a; font-weight: 500"],
        .role-info-card [style*="color: #333; font-weight: 500"] {
	color: var(--chat-text-primary) !important;
}

.sidebar-option-item [style*="color: #999"] {
	color: var(--chat-text-muted) !important;
}

.role-info-card > div > div [style*="color: #999"] {
	color: var(--chat-text-muted) !important;
}

.role-info-card > div > div [style*="color: #1a1a1a; font-weight: 500"],
        .role-info-card > div > div [style*="color: #333; font-weight: 500"] {
	color: var(--chat-text-primary) !important;
}

.role-creator-info,
        .role-interactions {
	color: var(--chat-text-secondary) !important;
}
        

        [style*="color: #1a1a1a"]:not([style*="background"]),
        [style*="color: #333"]:not([style*="background"]),
        [style*="color: #666"]:not([style*="background"]),
        [style*="color: #999"]:not([style*="background"]) {
	color: var(--chat-text-secondary) !important;
}
        
        [style*="color: #1a1a1a"][style*="font-weight"],
        [style*="color: #333"][style*="font-weight"],
        [style*="color: #1a1a1a; font-weight"],
        [style*="color: #333; font-weight"] {
	color: var(--chat-text-primary) !important;
}

.role-info-card i[style*="color: #666"],
        i[style*="color: #666"] {
	color: var(--chat-text-secondary) !important;
}

.btn-outline-primary,
        .btn-outline-secondary {
	color: var(--chat-text-primary);
	border-color: var(--chat-border);
}

.btn-outline-primary:hover,
        .btn-outline-secondary:hover {
	color: var(--chat-text-primary) !important;
	background: var(--chat-hover-bg) !important;
}

.text-muted {
	color: var(--chat-text-muted) !important;
}

a {
	color: var(--chat-text-secondary);
	transition: color 0.3s ease;
}

a:hover {
	color: var(--chat-text-primary);
}

.sidebar a,
        .right-sidebar a {
	color: var(--chat-text-muted);
}

.sidebar a:hover,
        .right-sidebar a:hover {
	color: var(--chat-text-secondary);
}

.pinned-message-item {
	display: flex;
	flex-direction: column;
	padding: 12px 16px;
	border-bottom: 1px solid var(--chat-border);
	transition: background 0.2s ease;
	color: var(--chat-text-primary);
}

.pinned-message-item:hover {
	background: var(--chat-hover-bg);
	color: var(--chat-text-primary) !important;
}

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

.pinned-message-type {
	font-size: 11px;
	padding: 2px 6px;
	border-radius: 3px;
	background: var(--chat-hover-bg);
	color: var(--chat-text-secondary);
}

.pinned-message-type.user {
	background: rgba(0, 123, 255, 0.1);
	color: #007bff;
}

.pinned-message-type.ai {
	background: rgba(40, 167, 69, 0.1);
	color: #28a745;
}

.pinned-message-delete-btn {
	background: none;
	border: none;
	padding: 4px 8px;
	cursor: pointer;
	color: #dc3545;
	border-radius: 4px;
	transition: all 0.2s ease;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
}

.pinned-message-delete-btn:hover {
	background: rgba(220, 53, 69, 0.1);
	color: #c82333;
}

.pinned-message-content {
	font-size: 13px;
	color: var(--chat-text-primary);
	line-height: 1.4;
	word-break: break-word;
	margin-bottom: 4px;
}

.pinned-message-time {
	font-size: 11px;
	color: var(--chat-text-muted);
}

.pinned-message-empty {
	padding: 12px 16px;
	color: var(--chat-text-muted);
	font-size: 13px;
	text-align: center;
	transition: color 0.3s ease;
}

.sidebar-option-submenu::-webkit-scrollbar {
	width: 4px;
}

.sidebar-option-submenu::-webkit-scrollbar-track {
	background: transparent;
}

.sidebar-option-submenu::-webkit-scrollbar-thumb {
	background: #ccc;
	border-radius: 2px;
}

.sidebar-option-submenu::-webkit-scrollbar-thumb:hover {
	background: #999;
}

.sidebar-toggle-btn {
	position: fixed;
	left: 20px;
	top: 20px;
	z-index: 999;
	background: #ffffff;
	border: 1px solid #e0e0e0;
	border-radius: 8px;
	padding: 8px 12px;
	cursor: pointer;
	font-size: 14px;
	transition: all 0.2s ease;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sidebar-toggle-btn:hover {
	background: #f5f5f5;
}

.sidebar-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	z-index: 100;
	display: none;
	opacity: 0;
	transition: opacity 0.2s ease;
	pointer-events: none;
}

.sidebar-overlay.show {
	pointer-events: auto;
	display: block;
	opacity: 1;
}

.chat-header-action-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	background: none;
	border: none;
	color: var(--chat-text-primary);
	font-size: 20px;
	cursor: pointer;
	padding: 8px;
	border-radius: 6px;
	transition: background-color 0.2s ease, color 0.3s ease;
	min-width: 36px;
	height: 36px;
}

.chat-header-action-btn:hover {
	background: var(--chat-hover-bg);
}

.mobile-menu-btn {
	display: none;
	background: none;
	border: none;
	color: var(--chat-text-primary);
	font-size: 20px;
	cursor: pointer;
	padding: 8px;
	border-radius: 6px;
	transition: background-color 0.2s ease, color 0.3s ease;
}

.mobile-menu-btn:hover {
	background: var(--chat-hover-bg);
}

@media (max-width: 1023px) {

	.main-layout {
		z-index: auto !important;
		position: relative !important;
		transform: none !important;
		opacity: 1 !important;
		isolation: auto !important;
		will-change: auto !important;
		filter: none !important;
	}

	.sidebar-close-btn {
		display: block !important;
	}

	.sidebar {
		position: fixed;
		left: 0;
		top: 0;
		width: 280px;
		max-width: 85vw;
		height: 100dvh;
		transform: translateX(-100%);
		z-index: 1011;
		box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
		pointer-events: auto;
		background: var(--chat-card-bg);
	}

	.sidebar.show {
		transform: translateX(0);
		z-index: 1011;
	}

	.right-sidebar {
		position: fixed;
		right: 0;
		top: 0;
		width: 300px;
		max-width: 85vw;
		height: 100dvh;
		transform: translateX(100%);
		z-index: 1000;
		box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
		pointer-events: auto;
		background: var(--chat-card-bg);
	}

	.right-sidebar.show {
		transform: translateX(0);
	}

	.mobile-menu-btn {
		display: block;
	}

	.chat-container {
		width: 100%;
	}
}

.chat-header {
	background: transparent;
	border-bottom: 1px solid var(--chat-border);
	padding: 12px 16px;
	flex-shrink: 0;
	display: none;
	transition: background-color 0.3s ease, border-color 0.3s ease;
}

.chat-header-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.chat-header-info {
	display: flex;
	align-items: center;
	gap: 12px;
}

.chat-header-avatar {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	object-fit: cover;
	border: 2px solid #e0e0e0;
}

.chat-header-name {
	font-size: 16px;
	font-weight: 600;
	color: var(--chat-text-primary);
	margin: 0;
	transition: color 0.3s ease;
}

.chat-header-subtitle {
	font-size: 12px;
	color: var(--chat-text-secondary);
	margin: 0;
	transition: color 0.3s ease;
}

@media (max-width: 1023px) {
	.chat-header {
		display: block;
	}

	.chat-header-action-btn {
		display: flex;
	}
}

@media (min-width: 1024px) {
	.chat-header-action-btn {
		display: flex;
	}
}

.chat-body {
	flex: 1;
	padding: 24px;
	background: var(--chat-bg);
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 100%;
	box-sizing: border-box;
	overflow-y: auto;
	overflow-x: hidden;
	min-height: 0;
	transition: background-color 0.3s ease, background-image 0.5s ease;
}

.chat-messages-container {
	position: relative;
}

.chat-messages-container::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	width: 100%;
	height: 100%;
	min-height: 100%;
	background-image: var(--role-bg-image, none);
	background-size: 100% auto;
	background-position: center top;
	background-repeat: repeat-y;
	opacity: 0.15;
	z-index: 0;
	pointer-events: none;
	filter: blur(5px);
	transition: opacity 0.5s ease, background-image 0.5s ease;
}

.chat-messages-container > * {
	position: relative;
	z-index: 1;
}

.chat-body::-webkit-scrollbar {
	width: 8px;
}

.chat-body::-webkit-scrollbar-track {
	background: var(--chat-scrollbar-track);
}

.chat-body::-webkit-scrollbar-thumb {
	background: var(--chat-scrollbar-thumb);
	border-radius: 4px;
}

.chat-body::-webkit-scrollbar-thumb:hover {
	background: var(--chat-text-muted);
}

.chat-body {
	scrollbar-width: thin;
	scrollbar-color: var(--chat-scrollbar-thumb) var(--chat-scrollbar-track);
}

.chat-messages-container {
	width: 100%;
	max-width: 900px;
	display: flex;
	flex-direction: column;
	align-items: center;
	margin: 0 auto;
	box-sizing: border-box;
}

.chat-footer {
	background: transparent;
	padding: 20px 0;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background-color 0.3s ease;
	max-width: 900px;
	width: 100%;
	margin: 0 auto;
	box-sizing: border-box;
}

.chat-footer form {
	width: 100%;
	padding: 0 24px;
	box-sizing: border-box;
}

.model-selector {
	display: flex;
	gap: 10px;
	align-items: center;
	flex-wrap: wrap;
}

.model-btn {
	padding: 8px 16px;
	border: 2px solid transparent;
	border-radius: 20px;
	background: rgba(255, 255, 255, 0.8);
	color: #333;
	text-decoration: none;
	transition: all 0.3s ease;
	font-size: 14px;
	font-weight: 500;
}

.model-btn:hover {
	background: rgba(255, 255, 255, 1);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.model-btn.active {
	background: #007bff;
	color: white;
	border-color: #007bff;
}

.message-wrapper {
	display: flex;
	flex-direction: column;
	margin-bottom: 24px;
	position: relative;
	width: 100%;
	max-width: 70%;
	align-items: flex-start;
	box-sizing: border-box;
	z-index: 1;
}

.message-wrapper:has(.message.user) {
	align-items: flex-end;
}

.message-wrapper:has(.message.ai) {
	align-items: flex-start;
}

.message-avatar-container {
	display: flex;
	flex-direction: row;
	align-items: center;
	gap: 8px;
	margin-bottom: 4px;
	padding: 0 4px;
	position: relative;
	width: 100%;
	justify-content: flex-start;
	min-height: 32px;
	height: 32px;
}

.message-wrapper:has(.message.user) .message-avatar-container {
	justify-content: flex-end;
}

.message-wrapper:has(.message.ai) .message-avatar-container {
	justify-content: flex-start;
}

.message-avatar {
	width: 32px;
	height: 32px;
	min-width: 32px;
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
	border: 2px solid rgba(0, 0, 0, 0.1);
}

.message-name {
	font-size: 13px;
	color: var(--chat-text-secondary);
	font-weight: 500;
	white-space: nowrap;
	order: 0;
	transition: color 0.3s ease;
}

.message-wrapper:has(.message.user) .message-avatar-container .message-avatar {
	order: 3;
}

.message-wrapper:has(.message.user) .message-avatar-container .message-name {
	order: 2;
}

.message-wrapper:has(.message.user) .message-avatar-container .message-time {
	order: 1;
}

.message-wrapper:has(.message.user) .message-avatar-container .message-actions {
	order: 0;
	margin-right: 0;
}

.message-wrapper:has(.message.ai) .message-avatar-container .message-actions {
	order: 999;
	margin-left: 0;
}

.message {
	min-width: 0;
	padding: 16px 20px;
	border-radius: 18px;
	word-wrap: break-word;
	word-break: break-word;
	overflow-wrap: break-word;
	position: relative;
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	width: fit-content;
	max-width: 100%;
	align-self: flex-start;
	z-index: 1;
}

.message-wrapper:has(.message.user) .message {
	align-self: flex-end;
}

.message-wrapper:has(.message.ai) .message {
	align-self: flex-start;
}

.message.user {
	background: #e5e7eb;
	color: var(--chat-text-primary);
}
        
        [data-theme="dark"] .message.user,
        [data-theme="dark-blue"] .message.user,
        [data-theme="dark-green"] .message.user,
        [data-theme="tech-dark"] .message.user {
	background: #2a2a3a;
	color: var(--chat-text-primary);
}

.message.ai {
	background: #f9fafb;
	color: var(--chat-text-primary);
}
        
        [data-theme="dark"] .message.ai,
        [data-theme="dark-blue"] .message.ai,
        [data-theme="dark-green"] .message.ai,
        [data-theme="tech-dark"] .message.ai {
	background: #1a1a2a;
	color: var(--chat-text-primary);
}

.message.ai:has(.message-content > .message-narrative),
        .message.ai:has(.message-content > .message-dialogue),
        .message.ai:has(.message-content > .message-emotion),
        .message.ai:has(.message-content > .message-action),
        .message.ai:has(.message-content > .message-gesture),
        .message.ai:has(.message-content > .message-psychology),
        .message.ai:has(.message-content > .message-environment),
        .message.ai:has(.message-content > .message-tone),
        .message.ai:has(.message-content > .message-voice),
        .message.ai:has(.message-content > .message-appearance) {
	background: transparent;
	padding: 0;
}
        
        [data-theme="dark"] .message.ai:has(.message-content > .message-narrative),
        [data-theme="dark"] .message.ai:has(.message-content > .message-dialogue),
        [data-theme="dark"] .message.ai:has(.message-content > .message-emotion),
        [data-theme="dark"] .message.ai:has(.message-content > .message-action),
        [data-theme="dark-blue"] .message.ai:has(.message-content > .message-narrative),
        [data-theme="dark-blue"] .message.ai:has(.message-content > .message-dialogue),
        [data-theme="dark-blue"] .message.ai:has(.message-content > .message-emotion),
        [data-theme="dark-blue"] .message.ai:has(.message-content > .message-action),
        [data-theme="dark-green"] .message.ai:has(.message-content > .message-narrative),
        [data-theme="dark-green"] .message.ai:has(.message-content > .message-dialogue),
        [data-theme="dark-green"] .message.ai:has(.message-content > .message-emotion),
        [data-theme="dark-green"] .message.ai:has(.message-content > .message-action),
        [data-theme="tech-dark"] .message.ai:has(.message-content > .message-narrative),
        [data-theme="tech-dark"] .message.ai:has(.message-content > .message-dialogue),
        [data-theme="tech-dark"] .message.ai:has(.message-content > .message-emotion),
        [data-theme="tech-dark"] .message.ai:has(.message-content > .message-action) {
	background: transparent;
}

.message-content {
	width: 100%;
	max-width: 100%;
	word-wrap: break-word;
	word-break: break-word;
	overflow-wrap: break-word;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.message-narrative,
        .message-dialogue,
        .message-emotion,
        .message-action,
        .message-gesture,
        .message-psychology,
        .message-environment,
        .message-tone,
        .message-voice,
        .message-appearance {
	position: relative;
	margin: 0;
	padding: 12px 16px;
	border-radius: 12px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
	transition: all 0.3s ease;
	display: flex;
	align-items: flex-start;
	gap: 8px;
}

.message-narrative::before,
        .message-dialogue::before,
        .message-emotion::before,
        .message-action::before,
        .message-gesture::before,
        .message-psychology::before,
        .message-environment::before,
        .message-tone::before,
        .message-voice::before,
        .message-appearance::before {
	content: '';
	flex-shrink: 0;
	width: 20px;
	height: 20px;
	background-size: contain;
	background-repeat: no-repeat;
	background-position: center;
	opacity: 0.7;
}

.message-narrative {
	text-align: left;
	font-style: italic;
	color: #6b7280;
	font-size: 14px;
	line-height: 1.7;
	background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
	border-left: 4px solid #9ca3af;
}

.message-narrative::before {
	content: '📖';
	font-style: normal;
}
        
        [data-theme="dark"] .message-narrative,
        [data-theme="dark-blue"] .message-narrative,
        [data-theme="dark-green"] .message-narrative,
        [data-theme="tech-dark"] .message-narrative {
	background: linear-gradient(135deg, rgba(75, 85, 99, 0.3) 0%, rgba(55, 65, 81, 0.3) 100%);
	color: #d1d5db;
	border-left-color: #6b7280;
}

.message-dialogue {
	font-size: 16px;
	line-height: 1.7;
	color: #1f2937;
	background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
	border-left: 4px solid #3b82f6;
	font-weight: 500;
}

.message-dialogue::before {
	content: '💬';
	font-style: normal;
}
        
        [data-theme="dark"] .message-dialogue,
        [data-theme="dark-blue"] .message-dialogue,
        [data-theme="dark-green"] .message-dialogue,
        [data-theme="tech-dark"] .message-dialogue {
	background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(37, 99, 235, 0.2) 100%);
	color: #e0e7ff;
	border-left-color: #60a5fa;
}

.message-emotion {
	font-size: 14px;
	line-height: 1.6;
	color: #c2410c;
	background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
	border-left: 4px solid #f59e0b;
	font-weight: 600;
	padding: 10px 14px;
}

.message-emotion::before {
	content: '😊';
	font-style: normal;
}
        
        [data-theme="dark"] .message-emotion,
        [data-theme="dark-blue"] .message-emotion,
        [data-theme="dark-green"] .message-emotion,
        [data-theme="tech-dark"] .message-emotion {
	background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(217, 119, 6, 0.2) 100%);
	color: #fbbf24;
	border-left-color: #f59e0b;
}

.message-action {
	font-size: 14px;
	line-height: 1.6;
	color: #4b5563;
	font-style: italic;
	background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
	border-left: 4px solid #9ca3af;
}

.message-action::before {
	content: '🎭';
	font-style: normal;
}
        
        [data-theme="dark"] .message-action,
        [data-theme="dark-blue"] .message-action,
        [data-theme="dark-green"] .message-action,
        [data-theme="tech-dark"] .message-action {
	background: linear-gradient(135deg, rgba(75, 85, 99, 0.2) 0%, rgba(55, 65, 81, 0.2) 100%);
	color: #d1d5db;
	border-left-color: #6b7280;
}

.message-gesture {
	font-size: 14px;
	line-height: 1.6;
	color: #4b5563;
	font-style: italic;
	background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
	border-left: 4px solid #0ea5e9;
}

.message-gesture::before {
	content: '👋';
	font-style: normal;
}
        
        [data-theme="dark"] .message-gesture,
        [data-theme="dark-blue"] .message-gesture,
        [data-theme="dark-green"] .message-gesture,
        [data-theme="tech-dark"] .message-gesture {
	background: linear-gradient(135deg, rgba(14, 165, 233, 0.2) 0%, rgba(2, 132, 199, 0.2) 100%);
	color: #7dd3fc;
	border-left-color: #0ea5e9;
}

.message-psychology {
	font-size: 14px;
	line-height: 1.6;
	color: #7c3aed;
	font-style: italic;
	background: linear-gradient(135deg, #f3e8ff 0%, #e9d5ff 100%);
	border-left: 4px solid #a855f7;
}

.message-psychology::before {
	content: '💭';
	font-style: normal;
}
        
        [data-theme="dark"] .message-psychology,
        [data-theme="dark-blue"] .message-psychology,
        [data-theme="dark-green"] .message-psychology,
        [data-theme="tech-dark"] .message-psychology {
	background: linear-gradient(135deg, rgba(168, 85, 247, 0.2) 0%, rgba(147, 51, 234, 0.2) 100%);
	color: #c084fc;
	border-left-color: #a855f7;
}

.message-environment {
	font-size: 14px;
	line-height: 1.6;
	color: #166534;
	font-style: italic;
	background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
	border-left: 4px solid #10b981;
}

.message-environment::before {
	content: '🌍';
	font-style: normal;
}
        
        [data-theme="dark"] .message-environment,
        [data-theme="dark-blue"] .message-environment,
        [data-theme="dark-green"] .message-environment,
        [data-theme="tech-dark"] .message-environment {
	background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(5, 150, 105, 0.2) 100%);
	color: #6ee7b7;
	border-left-color: #10b981;
}

.message-tone {
	font-size: 14px;
	line-height: 1.6;
	color: #7c2d12;
	font-weight: 500;
	background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
	border-left: 4px solid #d97706;
}

.message-tone::before {
	content: '🎵';
	font-style: normal;
}
        
        [data-theme="dark"] .message-tone,
        [data-theme="dark-blue"] .message-tone,
        [data-theme="dark-green"] .message-tone,
        [data-theme="tech-dark"] .message-tone {
	background: linear-gradient(135deg, rgba(217, 119, 6, 0.2) 0%, rgba(180, 83, 9, 0.2) 100%);
	color: #fbbf24;
	border-left-color: #d97706;
}

.message-voice {
	font-size: 14px;
	line-height: 1.6;
	color: #9a3412;
	background: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%);
	border-left: 4px solid #ea580c;
}

.message-voice::before {
	content: '🔊';
	font-style: normal;
}
        
        [data-theme="dark"] .message-voice,
        [data-theme="dark-blue"] .message-voice,
        [data-theme="dark-green"] .message-voice,
        [data-theme="tech-dark"] .message-voice {
	background: linear-gradient(135deg, rgba(234, 88, 12, 0.2) 0%, rgba(194, 65, 12, 0.2) 100%);
	color: #fdba74;
	border-left-color: #ea580c;
}

.message-appearance {
	font-size: 14px;
	line-height: 1.6;
	color: #6b21a8;
	background: linear-gradient(135deg, #f3e8ff 0%, #e9d5ff 100%);
	border-left: 4px solid #9333ea;
}

.message-appearance::before {
	content: '✨';
	font-style: normal;
}
        
        [data-theme="dark"] .message-appearance,
        [data-theme="dark-blue"] .message-appearance,
        [data-theme="dark-green"] .message-appearance,
        [data-theme="tech-dark"] .message-appearance {
	background: linear-gradient(135deg, rgba(147, 51, 234, 0.2) 0%, rgba(126, 34, 206, 0.2) 100%);
	color: #c084fc;
	border-left-color: #9333ea;
}

.message-narrative > *,
        .message-dialogue > *,
        .message-emotion > *,
        .message-action > *,
        .message-gesture > *,
        .message-psychology > *,
        .message-environment > *,
        .message-tone > *,
        .message-voice > *,
        .message-appearance > * {
	flex: 1;
}

.message-narrative:hover,
        .message-dialogue:hover,
        .message-emotion:hover,
        .message-action:hover,
        .message-gesture:hover,
        .message-psychology:hover,
        .message-environment:hover,
        .message-tone:hover,
        .message-voice:hover,
        .message-appearance:hover {
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.message-voice {
	font-style: italic;
}

.message-appearance {
	color: var(--chat-text-secondary);
}
        

        [data-theme="dark"] .message-gesture,
        [data-theme="dark-blue"] .message-gesture,
        [data-theme="dark-green"] .message-gesture,
        [data-theme="tech-dark"] .message-gesture,
        [data-theme="dark"] .message-environment,
        [data-theme="dark-blue"] .message-environment,
        [data-theme="dark-green"] .message-environment,
        [data-theme="tech-dark"] .message-environment,
        [data-theme="dark"] .message-voice,
        [data-theme="dark-blue"] .message-voice,
        [data-theme="dark-green"] .message-voice,
        [data-theme="tech-dark"] .message-voice,
        [data-theme="dark"] .message-appearance,
        [data-theme="dark-blue"] .message-appearance,
        [data-theme="dark-green"] .message-appearance,
        [data-theme="tech-dark"] .message-appearance {
	background: rgba(255, 255, 255, 0.05);
	color: var(--chat-text-secondary);
}
        
        [data-theme="dark"] .message-psychology,
        [data-theme="dark-blue"] .message-psychology,
        [data-theme="dark-green"] .message-psychology,
        [data-theme="tech-dark"] .message-psychology {
	background: rgba(102, 126, 234, 0.12);
	color: #8ba3ff;
}
        
        [data-theme="dark"] .message-tone,
        [data-theme="dark-blue"] .message-tone,
        [data-theme="dark-green"] .message-tone,
        [data-theme="tech-dark"] .message-tone {
	color: var(--chat-text-primary);
}

@media (max-width: 1023px) {
	.message {
		width: 100%;
		max-width: 100%;
		min-width: 0;
	}

	.message-wrapper {
		max-width: 100%;
	}
}

.message-header {
	font-size: 12px;
	opacity: 0.7;
	margin-bottom: 5px;
	display: flex;
	align-items: center;
	gap: 8px;
}

.message-time {
	font-size: 11px;
	color: var(--chat-text-secondary);
	margin-left: 6px;
	white-space: nowrap;
	flex-shrink: 0;
	transition: color 0.3s ease;
}

.message-wrapper:has(.message.ai) .message-avatar-container .message-time {
	order: 998;
}

.message-content {
	line-height: 1.6;
	color: var(--chat-text-primary);
	transition: color 0.3s ease;
}

.message-actions {
	position: relative;
	flex-shrink: 0;
	width: 24px;
	height: 24px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.message-action-trigger {
	background: transparent;
	border: none;
	cursor: pointer;
	padding: 4px;
	border-radius: 6px;
	opacity: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--chat-text-secondary);
	width: 24px;
	height: 24px;
	transition: opacity 0.2s ease, color 0.3s ease;
	pointer-events: none;
}

.message-wrapper:hover .message-actions .message-action-trigger {
	opacity: 0.6;
	pointer-events: auto;
}

.message-action-trigger:hover {
	opacity: 1;
	background: var(--chat-hover-bg);
}

.message-action-trigger i {
	font-size: 16px;
}

.message-action-menu {
	position: fixed !important;
	background: var(--chat-card-bg);
	border: 1px solid var(--chat-border);
	border-radius: 8px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	min-width: 200px;
	z-index: 10000000 !important;
	display: none;
	overflow: hidden;
	padding: 4px 0;
	transition: background-color 0.3s ease, border-color 0.3s ease;
	pointer-events: auto !important;
}

.message-action-menu.show {
	display: block;
}

.message-action-menu-item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 16px;
	cursor: pointer;
	font-size: 14px;
	color: var(--chat-text-primary);
	transition: background 0.2s ease, color 0.3s ease;
	border: none;
	background: none;
	width: 100%;
	text-align: left;
}

.message-action-menu-item:hover {
	background: var(--chat-hover-bg);
}

.message-action-menu-item i {
	font-size: 16px;
	width: 20px;
	color: var(--chat-text-secondary);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: color 0.3s ease;
}

.message-action-menu-item:hover i {
	color: var(--chat-text-primary);
}

.message-action-menu-item span {
	flex: 1;
}

.modal-overlay {
	position: fixed !important;
	top: 0 !important;
	left: 0 !important;
	right: 0 !important;
	bottom: 0 !important;
	z-index: 999999 !important;
	background: rgba(0, 0, 0, 0.5) !important;
	display: none !important;
	align-items: center !important;
	justify-content: center !important;
	z-index: 99999 !important;
	backdrop-filter: blur(2px) !important;
	opacity: 0 !important;
	transition: opacity 0.3s ease !important;
	pointer-events: auto !important;
}

.modal-overlay.show {
	display: flex !important;
}

.modal-overlay select,
        .modal-overlay #model,
        .modal-overlay #provider {
	z-index: 1000001 !important;
	position: relative;
}

.modal-overlay .modal-dialog {
	z-index: 1000000 !important;
	position: relative;
}

.modal-overlay.show {
	opacity: 1 !important;
	z-index: 99999 !important;
	pointer-events: auto !important;
}

.modal-overlay .modal-dialog {
	position: relative !important;
	z-index: 100000 !important;
	pointer-events: auto !important;
}

#confirmModal {
	z-index: 999999 !important;
	position: fixed !important;
}

#confirmModal.show {
	z-index: 999999 !important;
	display: flex !important;
	opacity: 1 !important;
	pointer-events: auto !important;
}

#confirmModal .modal-dialog {
	z-index: 1000000 !important;
	position: relative !important;
}

.modal-overlay .modal-dialog {
	pointer-events: auto;
}

.modal-overlay .modal-btn {
	pointer-events: auto;
	position: relative;
	z-index: 1;
}

.modal-overlay.show {
	display: flex;
	opacity: 1;
}

.modal-dialog {
	background: var(--chat-card-bg);
	border-radius: 12px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
	min-width: 320px;
	max-width: 500px;
	max-height: 90vh;
	width: 90%;
	transform: scale(0.9);
	transition: transform 0.3s ease, background-color 0.3s ease;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.modal-overlay.show .modal-dialog {
	transform: scale(1);
}

.modal-header {
	padding: 20px 24px 16px;
	border-bottom: 1px solid var(--chat-border);
	display: flex;
	align-items: center;
	justify-content: space-between;
	transition: border-color 0.3s ease;
}

.modal-title {
	font-size: 18px;
	font-weight: 600;
	color: var(--chat-text-primary);
	margin: 0;
	transition: color 0.3s ease;
}

.modal-close {
	background: none;
	border: none;
	font-size: 24px;
	color: var(--chat-text-muted);
	cursor: pointer;
	padding: 0;
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 6px;
	transition: all 0.2s ease;
}

.modal-close:hover {
	background: var(--chat-hover-bg);
	color: var(--chat-text-primary);
}

.modal-body {
	padding: 24px;
	color: var(--chat-text-secondary);
	font-size: 15px;
	line-height: 1.6;
	transition: color 0.3s ease;
}

.edit-modal-textarea {
	width: 100%;
	min-height: 100px;
	max-height: 300px;
	padding: 12px;
	border: 1px solid var(--chat-border);
	border-radius: 8px;
	background: var(--chat-input-bg);
	color: var(--chat-text-primary);
	font-size: 15px;
	line-height: 1.6;
	font-family: inherit;
	resize: vertical;
	transition: border-color 0.3s ease, background-color 0.3s ease, color 0.3s ease;
	box-sizing: border-box;
}

.edit-modal-textarea:focus {
	outline: none;
	border-color: var(--chat-primary);
	box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.edit-modal-textarea::placeholder {
	color: var(--chat-text-muted);
}

.modal-footer {
	padding: 16px 24px 20px;
	border-top: 1px solid var(--chat-border);
	display: flex;
	justify-content: flex-end;
	gap: 12px;
	transition: border-color 0.3s ease;
}

.modal-btn {
	padding: 10px 24px;
	border: none;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s ease;
	min-width: 80px;
}

.modal-btn-primary {
	background: #007bff !important;
	background-color: #007bff !important;
	color: #ffffff !important;
}

.modal-btn-primary:hover,
        .modal-overlay .modal-btn-primary:hover,
        .modal-dialog .modal-btn-primary:hover,
        .modal-footer .modal-btn-primary:hover {
	background: #0056b3 !important;
	background-color: #0056b3 !important;
	color: #ffffff !important;
}

.modal-btn-primary:hover *,
        .modal-btn-primary:hover i,
        .modal-overlay .modal-btn-primary:hover *,
        .modal-overlay .modal-btn-primary:hover i {
	color: #ffffff !important;
}

.modal-btn-secondary {
	background: var(--chat-hover-bg);
	color: var(--chat-text-primary);
}

.modal-btn-secondary:hover {
	background: var(--chat-hover-bg) !important;
	color: var(--chat-text-primary) !important;
}

.api-key-delete-btn:hover {
	background: #c82333 !important;
	border-color: #c82333 !important;
	color: white !important;
}

.right-sidebar .modal-btn {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	min-width: 0;
}

.right-sidebar .modal-btn i {
	flex-shrink: 0;
}

.right-sidebar .modal-btn span {
	flex-shrink: 1;
	overflow: hidden;
	text-overflow: ellipsis;
}

.sidebar-recharge-btn i,
        .sidebar-recharge-btn .bi-plus-circle {
	color: #ffffff !important;
}

.sidebar-recharge-btn:hover {
	color: #ffffff !important;
}

.sidebar-recharge-btn:hover i,
        .sidebar-recharge-btn:hover .bi-plus-circle {
	color: #ffffff !important;
}

.modal-btn-danger {
	background: #dc3545;
	color: #ffffff;
}

.share-modal-dialog {
	max-width: 480px;
}

.share-link-container {
	display: flex;
	gap: 8px;
	margin-bottom: 24px;
}

.share-link-input {
	flex: 1;
	padding: 12px 16px;
	border: 2px solid #e0e0e0;
	border-radius: 8px;
	font-size: 14px;
	color: #1a1a1a;
	background: #f8f9fa;
	transition: all 0.2s ease;
}

.share-link-input:focus {
	outline: none;
	border-color: #007bff;
	background: #ffffff;
}

.share-copy-btn {
	padding: 12px 24px;
	background: #007bff;
	color: #ffffff;
	border: none;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s ease;
	white-space: nowrap;
}

.share-copy-btn:hover {
	background: #0056b3;
}

.share-copy-btn.copied {
	background: #28a745;
}

.share-social-title {
	font-size: 14px;
	font-weight: 600;
	color: var(--chat-text-primary);
	margin-bottom: 16px;
	text-align: center;
	transition: color 0.3s ease;
}

.share-social-buttons {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 12px;
	margin-bottom: 8px;
}

.share-social-btn {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 16px 8px;
	background: var(--chat-hover-bg);
	border: 2px solid var(--chat-border);
	border-radius: 12px;
	cursor: pointer;
	transition: all 0.2s ease;
	text-decoration: none;
	color: var(--chat-text-primary);
}

.share-social-btn:hover {
	background: var(--chat-card-bg);
	border-color: #007bff;
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
}

.share-social-btn i {
	font-size: 28px;
	margin-bottom: 8px;
	color: var(--chat-text-secondary);
	transition: color 0.3s ease;
}

.share-social-btn.link i {
	color: #666;
}

.share-social-btn span {
	font-size: 12px;
	color: #666;
}

.share-social-btn:hover span {
	color: #1a1a1a;
}

.share-tip {
	text-align: center;
	font-size: 12px;
	color: #999;
	margin-top: 16px;
	padding-top: 16px;
	border-top: 1px solid #f0f0f0;
}

.load-more-container {
	text-align: center;
	padding: 15px;
	margin-bottom: 10px;
}

.load-more-container button {
	border-radius: 20px;
	padding: 8px 20px;
	font-size: 14px;
}

.load-more-container button:hover {
	transform: translateY(-2px);
	box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

.load-more-container button:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.chat-footer .input-group {
	position: relative;
	display: flex;
	align-items: flex-end;
	width: 80%;
	margin: 0 auto;
}

.chat-footer .message-input {
	border: 1px solid var(--chat-border) !important;
	border-radius: 24px !important;
	padding: 12px 60px 12px 20px !important;
	font-size: 15px !important;
	background: var(--chat-input-bg) !important;
	color: var(--chat-text-primary) !important;
	transition: all 0.2s ease;
	resize: none !important;
	min-height: 44px !important;
	max-height: 176px !important;
	width: 100% !important;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
	box-sizing: border-box !important;
	outline: none !important;
	user-select: text;
	-webkit-user-select: text;
	-moz-user-select: text;
	-ms-user-select: text;
	line-height: 1.5 !important;
	font-family: inherit;
	overflow-y: auto;
	margin: 0 !important;
	flex: 1 1 auto !important;
}

.chat-footer .message-input:focus {
	border-color: #007bff !important;
	box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1) !important;
}

.chat-footer .message-input::-webkit-scrollbar {
	width: 6px;
}

.chat-footer .message-input::-webkit-scrollbar-track {
	background: transparent;
}

.chat-footer .message-input::-webkit-scrollbar-thumb {
	background: rgba(0, 0, 0, 0.2);
	border-radius: 3px;
}

.chat-footer .message-input::-webkit-scrollbar-thumb:hover {
	background: rgba(0, 0, 0, 0.3);
}

.chat-footer .message-input {
	scrollbar-width: thin;
	scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

.chat-footer .message-input:focus {
	outline: none !important;
	border-color: #007bff !important;
	box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1) !important;
	background: var(--chat-input-bg) !important;
}

.chat-footer .send-btn {
	position: absolute !important;
	right: 6px !important;
	bottom: 6px !important;
	width: 32px !important;
	height: 32px !important;
	border-radius: 50% !important;
	background: #1a1a1a !important;
	border: none !important;
	color: white !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	transition: all 0.2s ease;
	cursor: pointer;
	z-index: 1000;
	font-size: 14px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
	flex-shrink: 0;
	outline: none;
	user-select: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	padding: 0 !important;
	margin: 0 !important;
}

.chat-footer .send-btn:hover:not(:disabled) {
	background: #333 !important;
	transform: scale(1.05);
}

.chat-footer .send-btn:active:not(:disabled) {
	transform: scale(0.95);
}

.chat-footer .send-btn:disabled {
	opacity: 0.5 !important;
	cursor: not-allowed;
	transform: none;
	background: #999 !important;
}

.chat-footer .send-btn i {
	font-size: 14px;
}

.loading {
	display: none;
	text-align: center;
	padding: 20px;
	color: var(--chat-text-secondary);
	transition: color 0.3s ease;
}

.typing-indicator {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 12px 16px;
	background: var(--chat-hover-bg);
	border-radius: 20px;
	border: 1px solid var(--chat-border);
	max-width: 200px;
	margin: 12px auto;
	transition: background-color 0.3s ease, border-color 0.3s ease;
}

.message.ai .typing-indicator {
	margin: 0;
	max-width: none;
	width: 100%;
	justify-content: center;
}

.typing-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #007bff;
	animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
	animation-delay: -0.32s;
}

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

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

.typing-text {
	font-size: 14px;
	color: var(--chat-text-secondary);
	font-style: italic;
	transition: color 0.3s ease;
}

.error-message-center {
	position: fixed;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	z-index: 10000;
	max-width: 500px;
	width: 90%;
	background: var(--chat-card-bg, #ffffff);
	border: 2px solid var(--chat-primary, #007bff);
	border-radius: 16px;
	padding: 24px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
	text-align: center;
}

.error-message-center .error-icon {
	font-size: 48px;
	color: #dc3545;
	margin-bottom: 16px;
}

.error-message-center .error-title {
	font-size: 20px;
	font-weight: 600;
	color: var(--chat-text-primary, #333);
	margin-bottom: 12px;
}

.error-message-center .error-content {
	font-size: 16px;
	color: var(--chat-text-secondary, #666);
	margin-bottom: 20px;
	line-height: 1.5;
}

.error-message-center .error-actions {
	display: flex;
	gap: 12px;
	justify-content: center;
	margin-top: 20px;
}

.error-message-center .error-btn {
	padding: 10px 24px;
	border: none;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s;
}

.error-message-center .error-btn-primary {
	background: var(--chat-primary, #007bff);
	color: #ffffff;
}

.error-message-center .error-btn-primary:hover {
	background: #0056b3;
}

.error-message-center .error-btn-secondary {
	background: var(--chat-hover-bg, #f0f0f0);
	color: var(--chat-text-primary, #333);
}

.error-message-center .error-btn-secondary:hover {
	background: var(--chat-border, #ddd);
}

.error-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	z-index: 9999;
}

.error-message {
	background: #f8d7da;
	color: #721c24;
	border: 1px solid #f5c6cb;
	border-radius: 10px;
	padding: 15px;
	margin-bottom: 15px;
}

.message.error-message {
	background: #f8d7da;
	color: #721c24;
	border: 1px solid #f5c6cb;
	border-radius: 20px;
	margin-right: auto;
	border-bottom-left-radius: 5px;
}

.error-tip {
	font-size: 0.85em;
	color: #6c757d;
	margin-top: 8px;
	font-style: italic;
}

@keyframes fadeInUp {
	from {
		opacity: 0;
		transform: translateY(20px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes typing {
	0%, 80%, 100% {
		transform: scale(0.8);
		opacity: 0.5;
	}

	40% {
		transform: scale(1);
		opacity: 1;
	}
}

.welcome-message {
	text-align: center;
	color: #666;
	padding: 40px 20px;
	font-size: 18px;
}

.welcome-icon {
	font-size: 48px;
	margin-bottom: 20px;
	opacity: 0.3;
}

@media (max-width: 1023px) {
	.chat-container {
		padding: 0;
	}

	.chat-body {
		padding: 12px;
	}

	.chat-footer {
		padding: 12px 16px;
	}

	.message {
		max-width: 90%;
	}

	.model-selector {
		justify-content: center;
	}

	.chat-header {
		display: block !important;
	}
}

@media (min-width: 1024px) {
	.chat-header {
		display: none !important;
	}
}

.model-selector-container {
	min-height: 500px;
}

.model-selector-close {
	background: none;
	border: none;
	font-size: 24px;
	color: var(--chat-text-primary);
	cursor: pointer;
	padding: 4px 8px;
	border-radius: 4px;
	transition: all 0.2s;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
}

.model-selector-close:hover {
	background: var(--chat-hover-bg, rgba(0, 0, 0, 0.05));
	color: var(--chat-text-primary);
	transform: scale(1.1);
}
        
        [data-theme="dark"] .model-selector-close,
        [data-theme="dark-blue"] .model-selector-close {
	color: var(--chat-text-primary);
}
        
        [data-theme="dark"] .model-selector-close:hover,
        [data-theme="dark-blue"] .model-selector-close:hover {
	background: rgba(255, 255, 255, 0.1);
}

.model-list-panel::-webkit-scrollbar,
        .model-detail-panel::-webkit-scrollbar,
        #modelSelectorContent::-webkit-scrollbar {
	width: 8px;
	height: 8px;
}

.model-list-panel::-webkit-scrollbar-track,
        .model-detail-panel::-webkit-scrollbar-track,
        #modelSelectorContent::-webkit-scrollbar-track {
	background: var(--chat-bg);
	border-radius: 4px;
}

.model-list-panel::-webkit-scrollbar-thumb,
        .model-detail-panel::-webkit-scrollbar-thumb,
        #modelSelectorContent::-webkit-scrollbar-thumb {
	background: var(--chat-border);
	border-radius: 4px;
	transition: background 0.2s;
}

.model-list-panel::-webkit-scrollbar-thumb:hover,
        .model-detail-panel::-webkit-scrollbar-thumb:hover,
        #modelSelectorContent::-webkit-scrollbar-thumb:hover {
	background: var(--chat-text-secondary, #999);
}

.model-list-panel,
        .model-detail-panel,
        #modelSelectorContent {
	scrollbar-width: thin;
	scrollbar-color: var(--chat-border) var(--chat-bg);
}

#modelSelectorContent {
	scrollbar-gutter: stable;
}

@media (max-width: 1023px) {
	#modelSelectorContent {
		max-height: calc(100dvh - 150px) !important;
	}
}

.model-list-panel {
	background: var(--chat-bg);
}

.model-detail-panel {
	background: var(--chat-card-bg);
}

@media (max-width: 1023px) {
	.model-detail-panel {
		max-height: none !important;
		min-height: auto !important;
	}
}

.model-item {
	padding: 12px;
	margin-bottom: 8px;
	border-radius: 8px;
	cursor: pointer;
	transition: all 0.2s;
	border: 2px solid transparent;
	background: var(--chat-card-bg);
}

.model-item:hover {
	background: var(--chat-hover-bg, rgba(0, 0, 0, 0.05));
	border-color: var(--chat-border);
}

.model-item.selected {
	border-color: #667eea;
	background: rgba(102, 126, 234, 0.1);
}

.model-item-header {
	display: flex;
	align-items: center;
	gap: 12px;
}

.model-icon {
	font-size: 24px;
	flex-shrink: 0;
}

.model-item-info {
	flex: 1;
	min-width: 0;
}

.model-name {
	font-weight: 600;
	font-size: 14px;
	color: var(--chat-text-primary);
	margin-bottom: 2px;
}

.model-name-en {
	font-size: 12px;
	color: var(--chat-text-secondary, #666);
}

.model-description {
	font-size: 13px;
	color: var(--chat-text-secondary, #666);
	line-height: 1.5;
	margin-top: 8px;
}

.model-item-content {
	width: 100%;
}

.model-detail {
	padding: 0;
}

.memory-settings-section {
	background: var(--chat-card-bg);
}

#memoryRoundsSlider {
	-webkit-appearance: none;
	appearance: none;
}

#memoryRoundsSlider::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 18px;
	height: 18px;
	background: #667eea;
	border-radius: 50%;
	cursor: pointer;
	transition: all 0.2s;
}

#memoryRoundsSlider::-webkit-slider-thumb:hover {
	background: #5568d3;
	transform: scale(1.1);
}

#memoryRoundsSlider::-moz-range-thumb {
	width: 18px;
	height: 18px;
	background: #667eea;
	border-radius: 50%;
	cursor: pointer;
	border: none;
	transition: all 0.2s;
}

#memoryRoundsSlider::-moz-range-thumb:hover {
	background: #5568d3;
	transform: scale(1.1);
}

.model-radar-chart {
	display: flex;
	justify-content: center;
	align-items: center;
	padding: 20px;
}

.version-list {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.model-versions {
	display: flex;
	flex-direction: column;
}

.version-list::-webkit-scrollbar {
	width: 8px;
}

.version-list::-webkit-scrollbar-track {
	background: var(--chat-bg);
	border-radius: 4px;
}

.version-list::-webkit-scrollbar-thumb {
	background: var(--chat-border);
	border-radius: 4px;
	transition: background 0.2s;
}

.version-list::-webkit-scrollbar-thumb:hover {
	background: var(--chat-text-secondary, #999);
}

.version-list {
	scrollbar-width: thin;
	scrollbar-color: var(--chat-border) var(--chat-bg);
}
        

        [data-theme="dark"] .version-list::-webkit-scrollbar-thumb,
        [data-theme="dark-blue"] .version-list::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, 0.3);
}
        
        [data-theme="dark"] .version-list::-webkit-scrollbar-thumb:hover,
        [data-theme="dark-blue"] .version-list::-webkit-scrollbar-thumb:hover {
	background: rgba(255, 255, 255, 0.5);
}

@media (max-width: 1023px) {
	.model-radar-chart {
		padding: 10px !important;
		margin-top: 16px !important;
		flex-shrink: 0;
	}

	.model-radar-chart canvas {
		max-width: 150px !important;
		max-height: 150px !important;
		width: 150px !important;
		height: 150px !important;
	}
}

.version-item {
	padding: 16px;
	border: 2px solid var(--chat-border);
	border-radius: 8px;
	cursor: pointer;
	transition: all 0.2s;
	background: var(--chat-card-bg);
}

.version-item:hover {
	border-color: #667eea;
	background: rgba(102, 126, 234, 0.05);
}

.version-item.selected {
	border-color: #667eea;
	background: rgba(102, 126, 234, 0.1);
}

.version-item input[type="radio"] {
	cursor: pointer;
}

#modelSelectorModalLabel {
	color: var(--chat-text-primary);
}

#modelSelectorModal {
	z-index: 10000 !important;
}

#modelSelectorModal .modal-backdrop {
	z-index: 9999 !important;
}

@media (max-width: 1023px) {
	#modelSelectorModal {
		z-index: 10000 !important;
	}

	#modelSelectorModal .modal-backdrop {
		z-index: 9999 !important;
	}

	#modelSelectorModal .modal-dialog {
		z-index: 10001 !important;
		position: relative;
	}
}
        

        [data-theme="dark"] .model-item,
        [data-theme="dark-blue"] .model-item {
	background: rgba(255, 255, 255, 0.05);
}
        
        [data-theme="dark"] .model-item:hover,
        [data-theme="dark-blue"] .model-item:hover {
	background: rgba(255, 255, 255, 0.1);
}
        
        [data-theme="dark"] .version-item,
        [data-theme="dark-blue"] .version-item {
	background: rgba(255, 255, 255, 0.05);
}
        
        [data-theme="dark"] .version-item:hover,
        [data-theme="dark-blue"] .version-item:hover {
	background: rgba(255, 255, 255, 0.1);
}
        

        [data-theme="dark"] .model-list-panel::-webkit-scrollbar-thumb,
        [data-theme="dark"] .model-detail-panel::-webkit-scrollbar-thumb,
        [data-theme="dark"] #modelSelectorContent::-webkit-scrollbar-thumb,
        [data-theme="dark-blue"] .model-list-panel::-webkit-scrollbar-thumb,
        [data-theme="dark-blue"] .model-detail-panel::-webkit-scrollbar-thumb,
        [data-theme="dark-blue"] #modelSelectorContent::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, 0.3);
}
        
        [data-theme="dark"] .model-list-panel::-webkit-scrollbar-thumb:hover,
        [data-theme="dark"] .model-detail-panel::-webkit-scrollbar-thumb:hover,
        [data-theme="dark"] #modelSelectorContent::-webkit-scrollbar-thumb:hover,
        [data-theme="dark-blue"] .model-list-panel::-webkit-scrollbar-thumb:hover,
        [data-theme="dark-blue"] .model-detail-panel::-webkit-scrollbar-thumb:hover,
        [data-theme="dark-blue"] #modelSelectorContent::-webkit-scrollbar-thumb:hover {
	background: rgba(255, 255, 255, 0.5);
}

.chat-characters-list-container {
	padding: 2rem;
	max-width: 1400px;
	margin: 0 auto;
}

.chat-characters-header {
	margin-bottom: 1.5rem;
}

.chat-characters-header h2 {
	font-size: 1.5rem;
	font-weight: 600;
	color: var(--chat-text-primary);
	margin: 0 0 1rem 0;
}

.chat-characters-tabs {
	display: flex;
	gap: 0.5rem;
	border-bottom: 2px solid var(--chat-border-color, var(--border-color, #3a3a3a));
}

.chat-characters-tab {
	padding: 0.75rem 1.5rem;
	background: transparent;
	border: none;
	border-bottom: 2px solid transparent;
	color: var(--chat-text-secondary);
	font-size: 0.95rem;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s ease;
	margin-bottom: -2px;
}

.chat-characters-tab:hover {
	color: var(--chat-text-primary);
}

.chat-characters-tab.active {
	color: var(--chat-primary-color, var(--primary-color, #007bff));
	border-bottom-color: var(--chat-primary-color, var(--primary-color, #007bff));
}

.chat-characters-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 1.5rem;
	margin-bottom: 2rem;
}

@media (min-width: 1600px) {
	.chat-characters-grid {
		grid-template-columns: repeat(4, 1fr);
	}
}

@media (max-width: 1200px) {
	.chat-characters-grid {
		grid-template-columns: repeat(3, 1fr);
	}
}

@media (max-width: 768px) {
	.chat-characters-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 1rem;
	}
}

@media (max-width: 480px) {
	.chat-characters-grid {
		grid-template-columns: 1fr;
	}
}

.chat-character-card {
	background: var(--chat-card-bg, var(--bg-card, #252525));
	border-radius: 12px;
	overflow: hidden;
	transition: all 0.3s ease;
	cursor: pointer;
	border: 1px solid var(--chat-border-color, var(--border-color, #3a3a3a));
	display: flex;
	flex-direction: column;
	position: relative;
}

.chat-character-card-image {
	width: 100%;
	aspect-ratio: 1;
	overflow: hidden;
	background: var(--chat-bg-secondary, var(--bg-secondary, #2d2d2d));
	position: relative;
}

.chat-character-card-image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center;
	transition: transform 0.3s ease;
}

.chat-character-card-avatar-placeholder {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--chat-bg-secondary, var(--bg-secondary, #2d2d2d));
	color: var(--chat-text-secondary, var(--text-secondary, #888));
	transition: background 0.3s ease, color 0.3s ease;
}

.chat-character-card-avatar-placeholder i {
	font-size: 3rem;
	opacity: 0.5;
	transition: color 0.3s ease, opacity 0.3s ease;
}

.chat-character-card-content {
	padding: 1rem;
	flex: 1;
	display: flex;
	flex-direction: column;
}

.chat-character-card-name {
	font-size: 1rem;
	font-weight: 600;
	color: var(--chat-text-primary);
	margin: 0 0 0.5rem 0;
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	text-overflow: ellipsis;
}

.chat-character-card-preview {
	font-size: 0.85rem;
	color: var(--chat-text-secondary);
	margin: 0 0 0.5rem 0;
	line-height: 1.5;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	text-overflow: ellipsis;
	flex: 1;
}

.chat-character-card-meta {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-top: auto;
	padding-top: 0.5rem;
	border-top: 1px solid var(--chat-border-color, var(--border-color, #3a3a3a));
}

.chat-character-card-time {
	font-size: 0.75rem;
	color: var(--chat-text-muted, var(--text-muted, #666));
}

.chat-character-card-actions {
	display: flex;
	gap: 0.5rem;
}

.chat-character-card-action-btn {
	background: transparent;
	border: none;
	color: var(--chat-text-secondary);
	cursor: pointer;
	padding: 0.25rem 0.5rem;
	border-radius: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.chat-characters-pagination {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 0.5rem;
	margin-top: 2rem;
}

.chat-characters-pagination-btn {
	padding: 0.5rem 1rem;
	background: var(--chat-card-bg, var(--bg-card, #252525));
	border: 1px solid var(--chat-border-color, var(--border-color, #3a3a3a));
	color: var(--chat-text-primary);
	border-radius: 6px;
	cursor: pointer;
	transition: all 0.2s ease;
}

.chat-characters-pagination-btn:hover:not(:disabled) {
	background: var(--chat-primary-color, var(--primary-color, #007bff));
	border-color: var(--chat-primary-color, var(--primary-color, #007bff));
	color: #fff;
}

.chat-characters-pagination-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.chat-characters-pagination-info {
	color: var(--chat-text-secondary);
	font-size: 0.9rem;
}

.chat-characters-loading,
        .chat-characters-empty {
	text-align: center;
	padding: 3rem;
	color: var(--chat-text-secondary);
}

.chat-characters-loading i {
	font-size: 2rem;
	margin-bottom: 1rem;
	display: block;
	animation: spin 1s linear infinite;
}

@keyframes spin {
	from {
		transform: rotate(0deg);
	}

	to {
		transform: rotate(360deg);
	}
}

.chat-characters-empty i {
	font-size: 3rem;
	margin-bottom: 1rem;
	display: block;
	opacity: 0.5;
}

/* Character card styles from /characters page */
.characters-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 1.5rem;
	margin-bottom: 2rem;
	max-width: 100%;
}

@media (min-width: 1400px) {
	.characters-grid {
		grid-template-columns: repeat(4, 1fr);
	}
}

@media (max-width: 1399px) and (min-width: 1050px) {
	.characters-grid {
		grid-template-columns: repeat(3, 1fr);
	}
}

@media (max-width: 1049px) and (min-width: 768px) {
	.characters-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (max-width: 767px) {
	.characters-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 1rem;
	}
}

@media (max-width: 480px) {
	.characters-grid {
		grid-template-columns: 1fr;
	}
}

.character-card {
	background: var(--card-bg, var(--chat-card-bg, #252525));
	border: 1px solid var(--border-color, var(--chat-border, #3a3a3a));
	border-radius: 12px;
	overflow: hidden;
	transition: all 0.3s ease;
	position: relative;
	display: flex;
	flex-direction: column;
	cursor: pointer;
}

.character-card:hover {
	transform: translateY(-4px);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.character-image {
	width: 100%;
	height: 0;
	padding-bottom: 150%;
	overflow: hidden;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	position: relative;
}

.character-image img {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center top;
	transition: transform 0.3s;
	z-index: 0;
}

.character-card:hover .character-image img {
	transform: scale(1.05);
}

.character-image-placeholder {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	color: white;
	font-size: 4rem;
	z-index: 0;
}

.character-info {
	padding: 1rem;
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.character-name {
	font-size: 1.25rem;
	font-weight: 600;
	margin: 0;
	color: var(--text-primary, var(--chat-text-primary));
}

.character-name a {
	color: var(--text-primary, var(--chat-text-primary));
	text-decoration: none;
	transition: color 0.2s;
}

.character-name a:hover {
	color: #667eea;
}

.character-description {
	color: var(--text-secondary, var(--chat-text-secondary));
	font-size: 0.9rem;
	line-height: 1.5;
	margin: 0;
	flex: 1;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	text-overflow: ellipsis;
}

.character-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.character-tags .tag {
	padding: 0.25rem 0.75rem;
	background: var(--bg-secondary, var(--chat-hover-bg, #2d2d2d));
	color: var(--text-secondary, var(--chat-text-secondary));
	border-radius: 12px;
	font-size: 0.75rem;
	transition: all 0.2s ease;
}

.character-tags .tag:hover {
	background: var(--primary-color, #667eea);
	color: #ffffff !important;
}

.character-stats {
	display: flex;
	gap: 1rem;
	padding-top: 0.5rem;
	border-top: 1px solid var(--border-color, var(--chat-border, #3a3a3a));
}

.character-stats .stat-item {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	color: var(--text-secondary, var(--chat-text-secondary));
	font-size: 0.85rem;
}

.character-stats .stat-item i {
	font-size: 0.9rem;
}

.character-actions {
	padding: 0 1rem 1rem;
	display: flex;
	gap: 0.5rem;
}

.character-actions .btn-view {
	flex: 1;
	padding: 0.75rem;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: white;
	text-align: center;
	text-decoration: none;
	border-radius: 6px;
	font-weight: 500;
	transition: transform 0.2s;
}

.character-actions .btn-view:hover {
	transform: translateY(-2px);
}

/* Age rating badge */
.age-badge {
	position: absolute;
	top: 0.75rem;
	right: 0.75rem;
	padding: 0.25rem 0.75rem;
	border-radius: 12px;
	font-size: 0.75rem;
	font-weight: 600;
	z-index: 10;
	background: #e8f5e9;
	border: 1px solid #c8e6c9;
	color: #2e7d32;
	pointer-events: none;
}

.age-badge.age-sfw {
	background: #e8f5e9;
	border-color: #c8e6c9;
	color: #2e7d32;
}

.age-badge.age-nsfw {
	background: #ffebee;
	border-color: #ffcdd2;
	color: #c62828;
}

.age-badge.age-mature {
	background: #fff3e0;
	border-color: #ffe0b2;
	color: #e65100;
}

.age-badge.age-teen {
	background: #e3f2fd;
	border-color: #bbdefb;
	color: #1565c0;
}