﻿/* Loading Styles */
.bundle-download-loading {
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: 1rem;
	margin: 1rem 0;
	background: #f8f9fa;
	border: 1px solid #e9ecef;
	border-radius: 0.5rem;
}

.loading-spinner {
	animation: spin 1s linear infinite;
	color: #007bff;
}

.loading-spinner svg {
	width: 24px;
	height: 24px;
}

.loading-text {
	flex: 1;
}

.loading-subtitle {
	color: #6c757d;
	font-size: 0.875rem;
	margin-top: 0.25rem;
}

.loading-dots {
	display: flex;
	gap: 0.25rem;
	margin-top: 0.5rem;
}

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

.loading-dots .dot:nth-child(1) { animation-delay: -0.32s; }
.loading-dots .dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes spin {
	0% { transform: rotate(0deg); }
	100% { transform: rotate(360deg); }
}

@keyframes loading-dots {
	0%, 80%, 100% {
		transform: scale(0);
		opacity: 0.5;
	}
	40% {
		transform: scale(1);
		opacity: 1;
	}
}

/* Modal Styles */
.modal {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 50000;
	display: flex;
	align-items: center;
	justify-content: center;
}

.modal-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	backdrop-filter: blur(4px);
	z-index: 50000;
}

.modal-dialog {
	position: relative;
	background: #fff;
	border-radius: 0.5rem;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
	max-width: 90%;
	max-height: 90vh;
	overflow: auto;
	z-index: 51000;
}

.settings-modal {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	display: none;
	align-items: flex-start;
	justify-content: center;
	padding-top: 5vh;
	z-index: 48000;
}

.settings-modal.active {
	display: flex;
}

.settings-content {
	position: relative;
	z-index: 48500;
}

.modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 1.5rem;
	border-bottom: 1px solid #e0e0e0;
}

.modal-header h2 {
	margin: 0;
	font-size: 1.5rem;
	color: #333;
}

.close-btn {
	background: none;
	border: none;
	font-size: 2rem;
	color: #999;
	cursor: pointer;
	padding: 0;
	width: 2rem;
	height: 2rem;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: color 0.2s;
}

.close-btn:hover {
	color: #333;
}

.modal-body {
	padding: 2rem;
}

.spinner {
	display: inline-block;
	width: 2rem;
	height: 2rem;
	border: 3px solid #f3f3f3;
	border-top: 3px solid #667eea;
	border-radius: 50%;
	animation: spin 1s linear infinite;
}

@keyframes spin {
	0% { transform: rotate(0deg); }
	100% { transform: rotate(360deg); }
}

/* Bridge modal */
.bridge-dialog {
	position: relative;
	background: radial-gradient(120% 120% at 20% 20%, #111827 0%, #0b0f19 45%, #0a0d17 100%);
	border: 1px solid #1f2937;
	border-radius: 18px;
	box-shadow: 0 22px 80px rgba(0, 0, 0, 0.45);
	color: #e5e7eb;
	width: min(820px, 94vw);
	max-height: clamp(540px, 86vh, 780px);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	backdrop-filter: saturate(1.05) blur(14px);
}

.bridge-dialog::before {
	content: '';
	position: absolute;
	inset: 0;
	background:
		radial-gradient(120% 120% at 15% 10%, rgba(79, 70, 229, 0.12), transparent 45%),
		radial-gradient(120% 120% at 85% 20%, rgba(34, 211, 238, 0.12), transparent 55%),
		linear-gradient(135deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0));
	pointer-events: none;
}

.bridge-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	padding: 1.5rem 1.75rem 1.25rem;
	border-bottom: 1px solid #1f2937;
}

.bridge-title {
	display: flex;
	align-items: center;
	gap: 1rem;
}

.bridge-icon-badge {
	width: clamp(30px, 5vw, 40px);
	height: clamp(30px, 5vw, 40px);
	border-radius: 14px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, #4f46e5 0%, #22d3ee 100%);
	color: #0b0f19;
	box-shadow: 0 10px 30px rgba(79, 70, 229, 0.35);
}

.bridge-heading {
	margin: 0;
	color: #f8fafc;
	font-size: clamp(1.05rem, 2.2vw, 1.35rem);
	line-height: 1.25;
}

.bridge-overline {
	margin: 0;
	text-transform: uppercase;
	font-size: 0.75rem;
	letter-spacing: 0.08em;
	color: #a5b4fc;
	font-weight: 700;
}

.bridge-subline {
	margin: 0.35rem 0 0 0;
	color: #9ca3af;
}

.bridge-close {
	background: #111827;
	border: 1px solid #1f2937;
	border-radius: 10px;
	padding: 0.35rem;
	width: 38px;
	height: 38px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: #cbd5e1;
	transition: all 0.15s ease;
}

.bridge-close:hover {
	color: #f8fafc;
	border-color: #4f46e5;
	box-shadow: 0 0 0 6px rgba(79, 70, 229, 0.12);
}

.bridge-body {
	padding: 1.1rem 1.35rem 1.35rem;
	background: linear-gradient(180deg, rgba(21, 24, 35, 0.96) 0%, rgba(11, 14, 23, 0.98) 100%);
	display: flex;
	flex-direction: column;
	gap: 0.85rem;
	flex: 1;
	min-height: 0;
	max-height: calc(86vh - 120px);
	overflow-y: auto;
}

.bridge-status {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	background: #0f172a;
	border: 1px solid #1f2937;
	padding: 0.7rem 0.9rem;
	border-radius: 12px;
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.bridge-status-dot {
	width: 10px;
	height: 10px;
	border-radius: 999px;
	background: linear-gradient(135deg, #22d3ee 0%, #4f46e5 100%);
	box-shadow: 0 0 0 6px rgba(79, 70, 229, 0.12);
}

.bridge-status-copy {
	display: flex;
	flex-direction: column;
	gap: 0.05rem;
}

.bridge-status-label {
	font-weight: 700;
	color: #e5e7eb;
}

.bridge-status-sub {
	color: #9ca3af;
	font-size: 0.95rem;
}

.bridge-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: 0.85rem;
	align-items: stretch;
}

.bridge-card {
	position: relative;
	background: #0f1625;
	border: 1px solid #1f2937;
	border-radius: 14px;
	padding: 1.1rem 1.2rem;
	box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
	display: flex;
	flex-direction: column;
	gap: 0.85rem;
	overflow: hidden;
	transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
	backdrop-filter: blur(6px);
}

.bridge-card::before {
	content: '';
	position: absolute;
	inset: -1px;
	background:
		radial-gradient(90% 90% at 20% 20%, rgba(79, 70, 229, 0.18), transparent 55%),
		radial-gradient(120% 120% at 80% 0%, rgba(34, 211, 238, 0.12), transparent 55%);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease;
	z-index: 0;
}

.bridge-card > * {
	position: relative;
	z-index: 1;
}

.bridge-card:hover {
	transform: translateY(-2px);
	border-color: #334155;
	box-shadow: 0 18px 46px rgba(0, 0, 0, 0.42);
}

.bridge-card:hover::before {
	opacity: 1;
}

.bridge-card-accent {
	border: 1px solid rgba(79, 70, 229, 0.6);
	background: linear-gradient(145deg, rgba(79, 70, 229, 0.12) 0%, rgba(15, 22, 37, 0.95) 60%);
	box-shadow: 0 18px 46px rgba(79, 70, 229, 0.18);
}

.bridge-error-state {
	border: 1px solid rgba(248, 113, 113, 0.35);
	background: linear-gradient(160deg, rgba(248, 113, 113, 0.12), #0f1625);
}

.bridge-card-compact {
	padding: 1rem 1.25rem;
}

.bridge-card-header {
	display: flex;
	align-items: flex-start;
	gap: 0.8rem;
}

.bridge-card-title {
	margin: 0 0 0.25rem 0;
	color: #e5e7eb;
	font-size: clamp(0.95rem, 1.9vw, 1.05rem);
}

.bridge-text {
	color: #9ca3af;
	margin: 0;
	font-size: clamp(0.88rem, 1.75vw, 0.98rem);
}

.bridge-field {
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
}

.bridge-label {
	color: #cbd5e1;
	font-weight: 600;
	font-size: 0.95rem;
}

.bridge-code-input {
	display: flex;
	gap: 0.75rem;
	align-items: center;
}

.bridge-input {
	flex: 1;
	padding: 0.85rem 0.9rem;
	border-radius: 12px;
	border: 1px solid #1f2937;
	background: #0b1220;
	color: #e5e7eb;
	font-size: 1.05rem;
	font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
	letter-spacing: 0.2em;
	text-transform: uppercase;
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.bridge-input:focus {
	outline: none;
	border-color: #4f46e5;
	box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.18);
}

.bridge-action svg,
.bridge-full-btn svg {
	width: 18px;
	height: 18px;
}

.bridge-action {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	white-space: nowrap;
	padding-inline: 1rem;
}

.bridge-hint {
	display: flex;
	gap: 0.75rem;
	align-items: flex-start;
	background: #0b1220;
	border: 1px dashed #1f2937;
	padding: 0.75rem 0.9rem;
	border-radius: 12px;
}

.bridge-hint-title {
	margin: 0 0 0.25rem 0;
	color: #e5e7eb;
	font-weight: 600;
}

.bridge-list {
	margin: 0;
	padding-left: 1rem;
	color: #9ca3af;
	line-height: 1.5;
}

.bridge-callout {
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
	padding: 0.75rem 0.95rem;
	background: rgba(79, 70, 229, 0.1);
	border: 1px solid rgba(79, 70, 229, 0.35);
	border-radius: 12px;
}

.bridge-card .bridge-full-btn {
	width: 100%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	font-weight: 700;
}

.bridge-full-btn.subtle {
	background: #0f172a;
	border-color: #1f2937;
	color: #e5e7eb;
}

.bridge-inline-note {
	margin-top: 0.75rem;
	padding: 0.65rem 0.75rem;
	background: #0b1220;
	border: 1px solid #1f2937;
	border-radius: 10px;
	color: #9ca3af;
}

.bridge-meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	color: #cbd5e1;
	font-weight: 600;
}

.bridge-meta-dim {
	color: #9ca3af;
	font-weight: 500;
}

.bridge-footnote {
	color: #6b7280;
	font-size: 0.85rem;
	margin: 0;
}

.bridge-error {
	color: #fca5a5;
	background: rgba(248, 113, 113, 0.08);
	border: 1px solid rgba(248, 113, 113, 0.3);
	border-radius: 10px;
	padding: 0.65rem 0.75rem;
	font-size: 0.95rem;
}

.bridge-spinner {
	width: 44px;
	height: 44px;
	border-radius: 999px;
	background:
		conic-gradient(from 90deg, rgba(79, 70, 229, 0.8), rgba(34, 211, 238, 0.9), rgba(79, 70, 229, 0.8));
	mask: radial-gradient(farthest-side, transparent 60%, black 61%);
	animation: bridge-spin 1.2s linear infinite;
}

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

.bridge-loading {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.75rem;
	padding: 2.25rem 1.25rem;
	background: #0f1625;
	border: 1px solid #1f2937;
	border-radius: 14px;
	text-align: center;
}

.bridge-success {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: 0.75rem;
	padding: 2.25rem 1.25rem;
	background: linear-gradient(160deg, rgba(16, 185, 129, 0.12), rgba(15, 118, 110, 0.08));
	border: 1px solid rgba(16, 185, 129, 0.35);
	border-radius: 14px;
}

.icon-circle {
	width: 42px;
	height: 42px;
	border-radius: 11px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: #0b1220;
	border: 1px solid #1f2937;
	color: #cbd5e1;
}

.icon-accent {
	background: linear-gradient(135deg, rgba(79, 70, 229, 0.2), rgba(34, 211, 238, 0.16));
	border-color: rgba(79, 70, 229, 0.6);
	color: #c7d2fe;
}

.icon-ghost {
	background: #0f172a;
}

.icon-ghost-play {
	background: radial-gradient(120% 120% at 35% 35%, rgba(79, 70, 229, 0.25), rgba(15, 23, 42, 0.9));
	border-color: rgba(79, 70, 229, 0.55);
	box-shadow:
		0 8px 20px rgba(0, 0, 0, 0.35),
		0 0 0 1px rgba(79, 70, 229, 0.35),
		0 0 18px rgba(79, 70, 229, 0.32);
}

.icon-success {
	background: rgba(16, 185, 129, 0.12);
	border-color: rgba(16, 185, 129, 0.5);
	color: #bbf7d0;
}

.bridge-hint .icon-circle,
.bridge-callout .icon-circle {
	min-width: 44px;
}

@media (max-width: 640px) {
	.bridge-header {
		flex-direction: column;
		align-items: flex-start;
		gap: 0.75rem;
		padding: 1.1rem 1.25rem 1rem;
	}
	.bridge-code-input {
		flex-direction: column;
		align-items: stretch;
	}
	.bridge-action {
		width: 100%;
		justify-content: center;
	}
	.bridge-body {
		padding: 1.1rem 1.25rem 1.25rem;
	}
	.bridge-card {
		padding: 1rem;
	}
	.bridge-status {
		padding: 0.75rem 0.9rem;
	}
}

/* Bridge Connected Button - Glowing SVG */
.btn-bridge-connected {
	padding: 0.5rem;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.3s ease;
	position: relative;
	box-shadow: 0 0 20px rgba(102, 126, 234, 0.5);
	animation: bridge-glow-pulse 2s ease-in-out infinite;
}

.btn-bridge-connected:hover {
	transform: scale(1.1);
	box-shadow: 0 0 30px rgba(102, 126, 234, 0.8);
}

.bridge-icon {
	color: white;
	filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.8));
	animation: bridge-icon-float 3s ease-in-out infinite;
}

@keyframes bridge-glow-pulse {
	0%, 100% {
		box-shadow: 0 0 20px rgba(102, 126, 234, 0.5),
					0 0 40px rgba(102, 126, 234, 0.3);
	}
	50% {
		box-shadow: 0 0 30px rgba(102, 126, 234, 0.8),
					0 0 60px rgba(102, 126, 234, 0.5);
	}
}

@keyframes bridge-icon-float {
	0%, 100% {
		transform: translateY(0px);
	}
	50% {
		transform: translateY(-2px);
	}
}

/* AI-Connect indicator */
.ai-status-pill {
	display: inline-flex;
	align-items: center;
	padding: 0.3rem 0.6rem;
	border-radius: 999px;
	font-size: 0.85rem;
	font-weight: 600;
	margin-left: 0.5rem;
}
.ai-status-on {
	background: #0f766e;
	color: #e0f2f1;
}
.ai-status-off {
	background: #3a3a3a;
	color: #d6d6d6;
}
.ai-test-result {
	padding: 0.35rem 0.6rem;
	border-radius: 6px;
}
.ai-test-success {
	background: #0f766e;
	color: #e0f2f1;
}
.ai-test-error {
	background: #7f1d1d;
	color: #fde8e8;
}
.ai-diff-panel {
	position: fixed;
	right: 1rem;
	bottom: 1rem;
	width: 360px;
	max-height: 70vh;
	background: #111;
	border: 1px solid #2d2d2d;
	border-radius: 8px;
	box-shadow: 0 12px 40px rgba(0,0,0,0.35);
	display: none;
	flex-direction: column;
	z-index: 9000;
}
.ai-diff-panel.active { display: flex; }
.ai-diff-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.75rem 1rem;
	border-bottom: 1px solid #2d2d2d;
}
.ai-diff-header-title {
	color: #e5e7eb;
	font-weight: 700;
}
.ai-diff-actions {
	display: flex;
	gap: 0.5rem;
}
.ai-diff-btn {
	background: #2563eb;
	color: #f8fafc;
	border: none;
	border-radius: 6px;
	padding: 0.4rem 0.7rem;
	cursor: pointer;
	font-weight: 600;
}
.ai-diff-btn.secondary {
	background: #374151;
	color: #e5e7eb;
}
.ai-diff-list {
	overflow-y: auto;
	padding: 0.75rem 1rem;
}
.ai-diff-item {
	border: 1px solid #2d2d2d;
	border-radius: 6px;
	padding: 0.6rem;
	margin-bottom: 0.6rem;
	background: #161616;
}
.ai-diff-item-title {
	font-weight: 700;
	color: #c7d2fe;
	margin-bottom: 0.25rem;
}
.ai-diff-summary {
	color: #e5e7eb;
	margin-bottom: 0.5rem;
}
.ai-diff-preview {
	border: 1px solid #2d2d2d;
	border-radius: 6px;
	padding: 0.5rem;
	margin-bottom: 0.5rem;
	background: #0f172a;
	max-height: 220px;
	overflow: auto;
}
.ai-diff-empty {
	color: #9ca3af;
	text-align: center;
	padding: 1rem 0;
}

/* AI inline suggestions in editor */
:root {
	--ai-inline-font-size: 0.74rem;
}
.monaco-editor .contentWidgets,
.monaco-editor .overflowingContentWidgets {
	overflow: visible !important;
	z-index: 38000;
	pointer-events: none;
}
.monaco-editor .contentWidgets .ai-inline-widget,
.monaco-editor .overflowingContentWidgets .ai-inline-widget {
	pointer-events: auto;
}
.monaco-editor .overflow-guard,
.monaco-editor .monaco-scrollable-element {
	overflow: visible !important;
}
.ai-suggestion-highlight {
	background: rgba(78, 201, 176, 0.18);
	border-bottom: 1px solid rgba(78, 201, 176, 0.55);
}
.ai-suggestion-glyph {
	background: #4ec9b0;
}
.ai-inline-widget,
.ai-inline-widget * {
	font-size: var(--ai-inline-font-size, 0.74rem);
	line-height: 1.35;
}
.ai-inline-widget {
	background: #2d2d30;
	border: 1px solid #3e3e42;
	border-radius: 6px;
	padding: 0.35rem 0.6rem;
	box-shadow: 0 8px 20px rgba(0,0,0,0.25);
	display: inline-flex;
	align-items: center;
	gap: 0.6rem;
	color: #cbd5e1;
	max-width: 720px;
	width: max-content;
	white-space: normal;
	line-height: 1.35;
	flex-direction: column;
	transform: translateY(6px);
	position: relative;
	z-index: 40000;
	user-select: none;
}
.ai-inline-widget.expanded {
	z-index: 40100;
}
.ai-inline-header {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	width: 100%;
	justify-content: space-between;
}
.ai-inline-summary {
	font-size: calc(var(--ai-inline-font-size, 0.74rem) * 0.95);
	color: #e5e7eb;
}
.ai-inline-diff {
	border: 1px solid #3e3e42;
	border-radius: 6px;
	padding: 0.35rem;
	background: #1f1f22;
	margin: 0.25rem 0;
	max-width: 720px;
	overflow: auto;
	font-family: 'Fira Code', 'SFMono-Regular', Consolas, monospace;
	white-space: pre-wrap;
}
.ai-inline-diff .diff-line,
.ai-inline-diff .diff-content,
.ai-inline-diff .diff-line-content,
.ai-inline-diff .diff-word {
	font-size: calc(var(--ai-inline-font-size, 0.74rem) * 0.95);
}
.ai-inline-diff .diff-line.diff-insert {
	background: rgba(78, 201, 176, 0.18);
}
.ai-inline-diff .diff-line.diff-delete {
	background: rgba(220, 53, 69, 0.18);
}
.ai-inline-diff .diff-content {
	color: #e5e7eb;
}
.ai-inline-actions {
	display: inline-flex;
	gap: 0.4rem;
}
.ai-inline-btn {
	border: 1px solid #3e3e42;
	background: #3e3e42;
	color: #e5e7eb;
	border-radius: 4px;
	padding: 0.25rem 0.55rem;
	cursor: pointer;
	font-size: calc(var(--ai-inline-font-size, 0.74rem) * 0.95);
	transition: background 0.15s ease, transform 0.1s ease;
}
.ai-inline-btn.accept {
	background: #4ec9b0;
	color: #0d1b2a;
}
.ai-inline-btn.decline {
	background: #3e3e42;
}
.ai-inline-btn.toggle {
	background: #3e3e42;
	color: #e5e7eb;
}
.ai-inline-btn:hover {
	transform: translateY(-1px);
}
.ai-inline-btn.monaco-diff {
	background: #1e40af;
	color: #e5e7eb;
}
.ai-inline-btn.copy-code {
	background: #3e3e42;
	color: #e5e7eb;
}

/* AI Diff Panel Toolbar */
.ai-diff-toolbar {
	display: flex;
	gap: 0.4rem;
	padding-bottom: 0.6rem;
	margin-bottom: 0.6rem;
	border-bottom: 1px solid #2d2d2d;
}
.ai-diff-btn-sm {
	font-size: 0.75rem;
	padding: 0.3rem 0.5rem;
}
.ai-diff-btn-monaco {
	background: #1e40af;
	color: #e5e7eb;
}
.ai-diff-btn-monaco:hover {
	background: #1d4ed8;
}

/* AI Monaco Diff Overlay */
.ai-monaco-diff-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.7);
	z-index: 50000;
	display: flex;
	flex-direction: column;
	padding: 1.5rem;
}
.ai-monaco-diff-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0.75rem 1rem;
	background: #1e1e1e;
	border: 1px solid #3e3e42;
	border-bottom: none;
	border-radius: 8px 8px 0 0;
}
.ai-monaco-diff-title {
	color: #4ec9b0;
	font-weight: 700;
	font-size: 0.95rem;
}
.ai-monaco-diff-header-actions {
	display: flex;
	gap: 0.5rem;
}
.ai-monaco-diff-container {
	flex: 1;
	border: 1px solid #3e3e42;
	border-radius: 0 0 8px 8px;
	overflow: hidden;
	min-height: 300px;
}

/* LaTeX Inline Preview Toolbar */
.latex-inline-preview-toolbar {
	display: flex;
	gap: 0.25rem;
	padding: 0.2rem 0.4rem;
	border-bottom: 1px solid rgba(78, 201, 176, 0.15);
	flex-wrap: wrap;
}
.latex-preview-tool-btn {
	background: rgba(255, 255, 255, 0.06);
	border: 1px solid rgba(255, 255, 255, 0.1);
	color: #9ca3af;
	border-radius: 3px;
	padding: 0.15rem 0.4rem;
	font-size: 0.7rem;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
	white-space: nowrap;
}
.latex-preview-tool-btn:hover {
	background: rgba(78, 201, 176, 0.15);
	color: #e5e7eb;
}
.latex-preview-tool-btn.active {
	background: rgba(78, 201, 176, 0.25);
	color: #4ec9b0;
	border-color: rgba(78, 201, 176, 0.4);
}
.latex-inline-preview.pinned {
	border-color: rgba(78, 201, 176, 0.5);
	box-shadow: 0 0 12px rgba(78, 201, 176, 0.15);
}

/* LaTeX Preview Popout */
.latex-preview-popout-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.7);
	z-index: 50000;
	display: flex;
	align-items: center;
	justify-content: center;
}
.latex-preview-popout-modal {
	background: #1e1e1e;
	border: 1px solid #3e3e42;
	border-radius: 10px;
	width: min(90vw, 700px);
	max-height: 85vh;
	display: flex;
	flex-direction: column;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
	overflow: hidden;
}
.latex-preview-popout-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0.75rem 1rem;
	border-bottom: 1px solid #3e3e42;
	color: #4ec9b0;
	font-weight: 700;
}
.latex-preview-popout-actions {
	display: flex;
	gap: 0.5rem;
}
.latex-preview-popout-body {
	padding: 2rem;
	overflow: auto;
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 1.4rem;
	color: #e5e7eb;
}
.latex-preview-popout-source {
	border-top: 1px solid #3e3e42;
	padding: 0.75rem 1rem;
	max-height: 200px;
	overflow: auto;
}
.latex-preview-popout-source-label {
	color: #9ca3af;
	font-size: 0.8rem;
	margin-bottom: 0.4rem;
}
.latex-preview-popout-source-code {
	font-family: 'Fira Code', 'SFMono-Regular', Consolas, monospace;
	font-size: 0.85rem;
	color: #c7d2fe;
	background: #111;
	border-radius: 4px;
	padding: 0.5rem;
	margin: 0;
	white-space: pre-wrap;
	word-break: break-word;
}
.latex-preview-popout-source-input {
	width: 100%;
	min-height: 96px;
	border: 1px solid #3e3e42;
	resize: vertical;
	outline: none;
}
.latex-preview-popout-source-input:focus {
	border-color: #4ec9b0;
	box-shadow: 0 0 0 2px rgba(78, 201, 176, 0.2);
}
.latex-preview-popout-sync-status {
	font-size: 0.75rem;
	font-weight: 600;
	color: #4ec9b0;
	background: rgba(78, 201, 176, 0.12);
	border: 1px solid rgba(78, 201, 176, 0.35);
	border-radius: 999px;
	padding: 0.15rem 0.55rem;
}
.latex-preview-popout-sync-status.paused {
	color: #fca5a5;
	background: rgba(239, 68, 68, 0.14);
	border-color: rgba(239, 68, 68, 0.35);
}

/* Editor Preview Toolbar (Math, Chemistry, TikZ) */
.editor-preview-toolbar {
	display: flex;
	gap: 0.4rem;
	padding: 0.6rem 0.75rem;
	border-top: 1px solid #2d2d2d;
	flex-wrap: wrap;
	background: rgba(0, 0, 0, 0.15);
}
.editor-preview-tool-btn {
	background: #2d2d30;
	border: 1px solid #3e3e42;
	color: #cbd5e1;
	border-radius: 6px;
	padding: 0.35rem 0.65rem;
	font-size: 0.8rem;
	cursor: pointer;
	font-weight: 500;
	transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
	white-space: nowrap;
}
.editor-preview-tool-btn:hover {
	background: #3e3e42;
	border-color: #4ec9b0;
	color: #e5e7eb;
	transform: translateY(-1px);
}
.editor-preview-tool-btn.primary {
	background: linear-gradient(135deg, #4ec9b0 0%, #3fb79f 100%);
	color: #0d1b2a;
	border-color: #3fb79f;
	font-weight: 600;
}
.editor-preview-tool-btn.primary:hover {
	box-shadow: 0 4px 12px rgba(78, 201, 176, 0.25);
}

/* Preamble Package Notification Banner */
.preamble-package-banner {
	position: fixed;
	top: 12px;
	left: 50%;
	transform: translateX(-50%) translateY(-60px);
	background: linear-gradient(135deg, #1e3a5f 0%, #1a2744 100%);
	border: 1px solid #2563eb;
	border-radius: 10px;
	padding: 0.6rem 1rem;
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	color: #e0f2fe;
	font-size: 0.85rem;
	font-weight: 500;
	box-shadow: 0 8px 24px rgba(37, 99, 235, 0.25);
	z-index: 60000;
	transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
	max-width: 90vw;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.preamble-package-banner.visible {
	transform: translateX(-50%) translateY(0);
}
.preamble-package-banner-icon {
	display: flex;
	align-items: center;
	color: #60a5fa;
	flex-shrink: 0;
}
.preamble-package-banner-text {
	overflow: hidden;
	text-overflow: ellipsis;
}

/* AI Chat Dock */
.ai-chat-peek {
	position: fixed;
	top: auto;
	left: 16px;
	bottom: 16px;
	right: auto;
	background: #2d2d30;
	color: #e5e7eb;
	border: 1px solid #3e3e42;
	border-radius: 10px;
	padding: 0.55rem 0.9rem;
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	font-weight: 700;
	box-shadow: 0 6px 18px rgba(0,0,0,0.35);
	cursor: pointer;
	z-index: 10000;
	transition: opacity 0.15s ease, transform 0.15s ease,
		box-shadow 0.15s ease;
	/* Prevent black bar artifacts */
	isolation: isolate;
	will-change: transform;
	pointer-events: all;
}
.ai-chat-peek.glow {
	background: linear-gradient(135deg, #2c3231 0%, #253430 100%);
	border-color: #3fb79f;
	box-shadow: 0 0 8px rgba(63, 183, 159, 0.22),
		0 0 16px rgba(63, 183, 159, 0.14);
	animation: ai-peek-glow 2.8s ease-in-out infinite;
	color: #e6fbf6;
}
.ai-chat-peek:hover {
	transform: translateY(-1px);
	box-shadow: 0 8px 22px rgba(0,0,0,0.4);
}
.ai-chat-peek.hidden {
	opacity: 0;
	pointer-events: none;
	transform: translateY(8px);
}
@keyframes ai-peek-glow {
	0%, 100% {
		box-shadow: 0 0 6px rgba(63, 183, 159, 0.18),
			0 0 12px rgba(63, 183, 159, 0.12);
	}
	50% {
		box-shadow: 0 0 10px rgba(63, 183, 159, 0.26),
			0 0 18px rgba(63, 183, 159, 0.16);
	}
}
.ai-chat-dock {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	height: 260px;
	background: #1f1f22;
	border-top: 1px solid #3e3e42;
	box-shadow: 0 -8px 28px rgba(0,0,0,0.35);
	display: none;
	flex-direction: column;
	z-index: 150;
	/* Prevent black bar artifacts */
	isolation: isolate;
	pointer-events: all;
}
.ai-chat-dock.active { display: flex; }
.ai-chat-header {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.65rem 1rem;
	border-bottom: 1px solid #3e3e42;
	background: #2d2d30;
}
.ai-chat-title {
	font-weight: 700;
	color: #cbd5e1;
	display: flex;
	align-items: center;
	gap: 0.4rem;
}
.ai-chat-controls {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	flex: 1;
}
.ai-chat-select {
	background: #252526;
	border: 1px solid #3e3e42;
	color: #cbd5e1;
	padding: 0.35rem 0.6rem;
	border-radius: 6px;
	min-width: 180px;
}
.ai-model-picker {
	position: relative;
}
.ai-model-picker-toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	justify-content: space-between;
	min-width: 220px;
}
.ai-model-picker-list {
	position: absolute;
	top: 105%;
	left: 0;
	background: #1e1f22;
	border: 1px solid #3e3e42;
	border-radius: 6px;
	min-width: 260px;
	max-height: 360px;
	overflow-y: auto;
	z-index: 50;
	box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.ai-model-item {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.35rem 0.6rem;
	cursor: pointer;
	color: #e5e7eb;
}
.ai-model-item:hover {
	background: #2b2d31;
}
.ai-model-star {
	color: #9ca3af;
	font-size: 0.95rem;
	min-width: 1.2rem;
	text-align: center;
	cursor: pointer;
	user-select: none;
}
.ai-model-star.filled {
	color: #fbbf24;
}
.ai-model-label {
	flex: 1;
	color: #e5e7eb;
}
.ai-model-provider {
	color: #9ca3af;
	font-size: 0.9rem;
}
.ai-model-caret {
	font-size: 0.85rem;
	color: #cbd5e1;
}
.ai-chat-btn {
	background: linear-gradient(135deg, #4ec9b0 0%, #3fb79f 100%);
	color: #0d1b2a;
	border: 1px solid #3e3e42;
	border-radius: 6px;
	padding: 0.45rem 0.85rem;
	cursor: pointer;
	font-weight: 600;
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.ai-chat-btn:hover {
	transform: translateY(-1px);
	box-shadow: 0 6px 18px rgba(78, 201, 176, 0.25);
}
.ai-chat-btn.secondary {
	background: #3e3e42;
	border-color: #3e3e42;
	color: #e5e7eb;
	box-shadow: none;
}
.ai-chat-btn.secondary:hover {
	box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}
.ai-chat-btn.danger {
	background: #dc3545;
	border-color: #b52a39;
	color: #fef2f2;
}
.ai-chat-body {
	display: grid;
	grid-template-columns: 260px 1fr;
	grid-template-rows: 1fr;
	flex: 1;
	overflow: hidden;
}
.ai-suggestion-highlight {
	background: rgba(78, 201, 176, 0.18);
	border-bottom: 1px solid rgba(78, 201, 176, 0.55);
}
.ai-suggestion-glyph {
	background: #4ec9b0;
}
.ai-chat-history {
	border-right: 1px solid #1f2937;
	background: #252526;
	overflow-y: auto;
	padding: 0.75rem;
}
.ai-chat-history-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	margin-bottom: 0.5rem;
}
.ai-chat-history h4 {
	margin: 0 0 0.5rem 0;
	color: #9ca3af;
	font-size: 0.9rem;
}
.ai-chat-history-new {
	background: #111827;
	border: 1px solid #374151;
	color: #e5e7eb;
	padding: 0.3rem 0.6rem;
	border-radius: 6px;
	cursor: pointer;
	font-size: 0.85rem;
}
.ai-chat-history-new:hover {
	border-color: #4ec9b0;
	color: #c7f2e9;
}
.ai-chat-history-list {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}
.ai-chat-history-item {
	padding: 0.55rem;
	border: 1px solid #3e3e42;
	border-radius: 6px;
	color: #e5e7eb;
	cursor: pointer;
	background: #1f1f22;
	transition: border-color 0.15s ease, background 0.15s ease;
}
.ai-chat-history-item.active {
	border-color: #4ec9b0;
	background: #1b1b1f;
}
.ai-chat-history-item:hover {
	border-color: #4ec9b0;
	background: #252526;
}
.ai-chat-history-title {
	font-weight: 600;
	margin-bottom: 0.15rem;
}
.ai-chat-history-preview {
	color: #9ca3af;
	font-size: 0.85rem;
	line-height: 1.3;
}
.ai-chat-thread {
	display: flex;
	flex-direction: column;
	height: 100%;
	overflow: hidden;
}
.ai-chat-log {
	flex: 1;
	overflow-y: auto;
	padding: 0.75rem 1rem;
	display: flex;
	flex-direction: column;
	gap: 0.65rem;
}
.ai-chat-msg {
	padding: 0.65rem 0.75rem;
	border-radius: 8px;
	max-width: 90%;
	line-height: 1.5;
	white-space: pre-wrap;
	word-break: break-word;
}
.ai-chat-msg.user {
	align-self: flex-end;
	background: #1d4ed8;
	color: #e0f2fe;
}
.ai-chat-msg.assistant {
	align-self: flex-start;
	background: #252526;
	border: 1px solid #3e3e42;
	color: #e5e7eb;
}
.ai-chat-msg.error {
	align-self: flex-start;
	background: #7f1d1d;
	color: #fde8e8;
	border: 1px solid #991b1b;
}
.ai-chat-composer {
	border-top: 1px solid #1f2937;
	padding: 0.75rem 1rem;
	background: #1f1f22;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}
.ai-chat-textarea {
	width: 100%;
	min-height: 72px;
	max-height: 150px;
	resize: vertical;
	background: #252526;
	border: 1px solid #3e3e42;
	color: #e5e7eb;
	padding: 0.6rem;
	border-radius: 6px;
	font-family: inherit;
}
.ai-chat-actions {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
}
.ai-chat-context {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	color: #9ca3af;
	font-size: 0.9rem;
	flex-wrap: wrap;
}
.ai-chat-context label {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	cursor: pointer;
}
.ai-chat-footer-buttons {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}
.ai-chat-resize-handle {
	height: 6px;
	background: linear-gradient(90deg, transparent 0%, #1f2937 20%, #2563eb 50%, #1f2937 80%, transparent 100%);
	cursor: ns-resize;
	flex-shrink: 0;
}
.ai-chat-status {
	color: #9ca3af;
	font-size: 0.9rem;
}
.ai-chat-status.ok { color: #22c55e; }
.ai-chat-status.warn { color: #eab308; }
.ai-chat-status.err { color: #ef4444; }

/* Button Text Variant - für Download-Links der älteren Versionen */
.btn-text {
	background: transparent;
	color: #cbd5e1;
	border: 1px solid #3e3e42;
	transition: all 0.2s ease;
}

.btn-text:hover {
	background: #1f2937;
	border-color: #4f46e5;
	color: #e5e7eb;
}


