/* ============================================================================
   MAIN STYLES - LaTeX Split-View Editor
   ============================================================================ */

/* Import main file selector styles */
@import url('main-file-selector.css');

:root {
	/* Theme Variables - Central color scheme for consistent theming */
	--theme-bg-primary: #1e1e1e;
	--theme-bg-secondary: #2d2d30;
	--theme-bg-tertiary: #252526;
	--theme-bg-accent: #0f1625;
	--theme-bg-hover: #3e3e42;
	--theme-bg-active: #4e4e52;

	--theme-border-primary: #3e3e42;
	--theme-border-secondary: #1f2937;
	--theme-border-accent: rgba(79, 70, 229, 0.6);

	--theme-text-primary: #e5e7eb;
	--theme-text-secondary: #9ca3af;
	--theme-text-accent: #4ec9b0;
	--theme-text-muted: #6b7280;

	--theme-primary: #4ec9b0;
	--theme-primary-hover: #5fd9c0;
	--theme-secondary: #3e3e42;
	--theme-secondary-hover: #4e4e52;

	--theme-gradient-primary: linear-gradient(135deg, #4f46e5 0%, #22d3ee 100%);
	--theme-gradient-secondary: linear-gradient(180deg, rgba(21, 24, 35, 0.96) 0%, rgba(11, 14, 23, 0.98) 100%);

	--theme-shadow-primary: 0 8px 32px rgba(0, 0, 0, 0.5);
	--theme-shadow-secondary: 0 12px 30px rgba(0, 0, 0, 0.4);
	--theme-shadow-accent: 0 0 0 6px rgba(79, 70, 229, 0.12);
}

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

html {
	position: relative;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
}

body {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	position: relative;
	top: 0;
	left: 0;
	width: 100%;
	height: 100vh;
	height: 100dvh;
	overflow: hidden;
	background: var(--theme-bg-primary);
}

/* ============================================================================
   HEADER
   ============================================================================ */

.header {
	position: sticky;
	top: 0;
	left: 0;
	right: 0;
	background: var(--theme-bg-secondary);
	color: var(--theme-text-primary);
	padding: 0.75rem 1.5rem;
	display: flex;
	justify-content: space-between;
	align-items: center;
	border-bottom: 1px solid var(--theme-border-primary);
	height: 50px;
	min-height: 50px;
	z-index: 21000;
	flex-shrink: 0;
}

.header-left {
	display: flex;
	align-items: center;
	gap: 1rem;
}

.logo {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-size: 1.2rem;
	font-weight: 700;
	color: #4ec9b0;
}

.logo-icon {
	width: 26px;
	height: 26px;
}

.logo-text {
	color: #4ec9b0;
}

.project-name-wrapper {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.project-name {
	color: #ccc;
	font-size: 0.9rem;
}

.project-name.project-name-link {
	cursor: pointer;
}

.project-name.project-name-link:hover {
	color: var(--theme-text-primary);
	text-decoration: underline;
}

.project-name.project-name-link:focus-visible {
	outline: 2px solid var(--theme-text-accent);
	outline-offset: 2px;
	border-radius: 4px;
}

.project-select-btn {
	background: transparent;
	border: none;
	color: #888;
	cursor: pointer;
	padding: 0.25rem;
	border-radius: 4px;
	transition: all 0.2s;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0.7;
}

.project-select-btn:hover {
	background: #3e3e42;
	color: #4ec9b0;
	opacity: 1;
}

.project-select-btn:active {
	background: #2e2e32;
}

.header-center {
	display: flex;
	gap: 0.5rem;
	align-items: center;
}

.header-right {
	display: flex;
	gap: 0.5rem;
	align-items: center;
}

.settings-btn {
	background: transparent;
	border: none;
	color: #ccc;
	font-size: 1.3rem;
	cursor: pointer;
	padding: 0.5rem;
	border-radius: 4px;
	transition: all 0.2s;
	display: flex;
	align-items: center;
}

.settings-btn:hover {
	background: #3e3e42;
	color: #4ec9b0;
}

.settings-icon {
	width: 20px;
	height: 20px;
	flex-shrink: 0;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

.btn {
	padding: 0.5rem 1rem;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	font-size: 0.85rem;
	font-weight: 600;
	transition: all 0.2s;
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.btn-icon {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
}

.btn-primary {
	background: var(--theme-primary);
	color: var(--theme-bg-primary);
}

.btn-primary:hover {
	background: var(--theme-primary-hover);
}

.btn-success {
	background: #28a745;
	color: var(--theme-text-primary);
}

.btn-success:hover {
	background: #34b350;
}

.btn-info {
	background: #007bff;
	color: var(--theme-text-primary);
}

.btn-info:hover {
	background: #0069d9;
}

.btn-danger {
	background: #dc3545;
	color: var(--theme-text-primary);
}

.btn-secondary {
	background: var(--theme-secondary);
	color: var(--theme-text-primary);
}

.btn-secondary:hover {
	background: var(--theme-secondary-hover);
}

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

/* ============================================================================
   COMPILE SPLIT-BUTTON
   ============================================================================ */

.compile-split-btn {
	position: relative;
	display: inline-flex;
	align-items: center;
	--compile-split-height: 34px;
}

.compile-split-btn .compile-main {
	height: var(--compile-split-height);
	border-top-right-radius: 0;
	border-bottom-right-radius: 0;
	border-right: 1px solid rgba(0, 0, 0, 0.2);
}

.compile-split-btn .compile-dropdown-toggle {
	height: var(--compile-split-height);
	border-top-left-radius: 0;
	border-bottom-left-radius: 0;
	padding: 0 0.65rem;
	min-width: 34px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.compile-split-btn .compile-dropdown-toggle svg {
	width: 11px;
	height: 7px;
	display: block;
}

.compile-dropdown-menu {
	position: absolute;
	top: calc(100% + 4px);
	right: 0;
	width: 280px;
	background: var(--theme-bg-secondary, #1e1e1e);
	border: 1px solid var(--theme-border, #333);
	border-radius: 8px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
	z-index: 10000;
	opacity: 0;
	visibility: hidden;
	transform: translateY(-4px);
	transition: opacity 0.15s, visibility 0.15s, transform 0.15s;
	padding: 6px 0;
}

.compile-dropdown-menu.open {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.compile-dropdown-section {
	padding: 2px 0;
}

.compile-dropdown-item {
	display: grid;
	grid-template-columns: 20px 1fr auto;
	align-items: center;
	gap: 8px;
	width: 100%;
	padding: 7px 12px;
	background: none;
	border: none;
	color: var(--theme-text-primary, #ccc);
	font-size: 0.85rem;
	cursor: pointer;
	text-align: left;
	white-space: nowrap;
}

.compile-dropdown-item:hover {
	background: var(--theme-bg-hover, #2a2a2a);
}

.compile-dropdown-item.active {
	color: var(--theme-primary, #4ec9b0);
}

.compile-dropdown-check {
	width: 20px;
	text-align: center;
	color: var(--theme-primary, #4ec9b0);
	font-size: 0.9rem;
}

.compile-dropdown-hint {
	color: #666;
	font-size: 0.75rem;
}

.compile-dropdown-divider {
	height: 1px;
	background: var(--theme-border, #333);
	margin: 4px 0;
}

.compile-dropdown-item.toggle-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	cursor: default;
	padding: 7px 12px;
}

.compile-dropdown-item.delay-selector-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 4px 12px 7px 12px;
}

.compile-dropdown-divider {
	height: 1px;
	background: var(--theme-border-primary, #3e3e42);
	margin: 4px 8px;
}

.delay-label {
	font-size: 0.8rem;
	color: var(--theme-text-secondary, #999);
}

.compile-delay-select {
	background: var(--theme-bg-active, #2a2a2a);
	color: var(--theme-text-primary, #e0e0e0);
	border: 1px solid var(--theme-border, #444);
	border-radius: 4px;
	padding: 2px 6px;
	font-size: 0.78rem;
	cursor: pointer;
	outline: none;
	transition: border-color 0.2s, box-shadow 0.2s;
}

.compile-delay-select:hover {
	border-color: #4ec9b0;
}

.compile-delay-select:focus {
	border-color: #4ec9b0;
	box-shadow: 0 0 0 2px rgba(78, 201, 176, 0.2);
}

.compile-delay-select option {
	background: var(--theme-bg-secondary, #1e1e1e);
	color: var(--theme-text-primary, #e0e0e0);
}

/* ============================================================================
   TOGGLE SWITCH
   ============================================================================ */

.toggle-switch {
	position: relative;
	display: inline-block;
	width: 50px;
	height: 26px;
}

.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(--theme-bg-active);
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	border-radius: 26px;
	box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-slider:hover {
	background-color: var(--theme-secondary-hover);
	box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2), 0 0 0 2px rgba(78, 201, 176, 0.1);
}

.toggle-slider:before {
	position: absolute;
	content: "";
	height: 20px;
	width: 20px;
	left: 3px;
	top: 50%;
	transform: translate(0, -50%);
	background: linear-gradient(180deg, var(--theme-text-primary) 0%, #f0f0f0 100%);
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	border-radius: 50%;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
}

input:checked + .toggle-slider {
	background-color: #4ec9b0;
	box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1), 0 0 0 2px rgba(78, 201, 176, 0.2);
}

input:checked + .toggle-slider:hover {
	background-color: #5fd9c0;
	box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1), 0 0 0 2px rgba(78, 201, 176, 0.3);
}

input:checked + .toggle-slider:before {
	transform: translate(24px, -50%);
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.15);
}

input:focus + .toggle-slider {
	outline: 2px solid rgba(78, 201, 176, 0.4);
	outline-offset: 2px;
}

.toggle-label {
	margin-left: 0.5rem;
	color: #ccc;
	font-size: 0.85rem;
}

/* Small toggle variant (for dropdown menus) */
.toggle-switch-sm {
	width: 36px;
	height: 20px;
	flex-shrink: 0;
}

.toggle-switch-sm .toggle-slider:before {
	height: 14px;
	width: 14px;
	left: 3px;
	top: 50%;
}

.toggle-switch-sm input:checked + .toggle-slider:before {
	transform: translate(16px, -50%);
}

/* ============================================================================
   STATUS INDICATOR
   ============================================================================ */

.status-indicator {
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
	padding: 0.5rem;
}

.status-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	position: relative;
}

.status-icon {
	width: 20px;
	height: 20px;
	transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
	position: relative;
	filter: drop-shadow(0 0 4px currentColor);
}

/* Idle Status - Gear Icon */
.status-badge.status-idle .status-icon {
	color: #888;
	filter: drop-shadow(0 0 4px rgba(136, 136, 136, 0.5));
	transition: transform 0.3s ease, filter 0.3s ease;
	animation: idle-glow-pulse 3s ease-in-out infinite;
}

@keyframes idle-glow-pulse {
	0%, 100% {
		filter: drop-shadow(0 0 4px rgba(136, 136, 136, 0.5));
	}
	50% {
		filter: drop-shadow(0 0 6px rgba(136, 136, 136, 0.7));
	}
}

.status-badge.status-idle .status-icon:hover {
	transform: rotate(15deg);
	color: #aaa;
	filter: drop-shadow(0 0 8px rgba(170, 170, 170, 0.8));
}

.status-badge.status-idle .status-icon path {
	stroke: currentColor;
	fill: none;
}

/* Compiling Status - Spinner */
.status-badge.status-compiling .status-icon {
	color: #ffc107;
	filter: drop-shadow(0 0 8px rgba(255, 193, 7, 0.6));
	animation: compiling-spin 1.5s linear infinite;
}

.status-badge.status-compiling .status-icon circle {
	stroke: currentColor;
	fill: none;
	stroke-width: 2;
	stroke-dasharray: 40 20;
	stroke-linecap: round;
	animation: compiling-dash 2s ease-in-out infinite;
}

/* Success Status - Checkmark */
.status-badge.status-success .status-icon {
	color: #28a745;
	filter: drop-shadow(0 0 10px rgba(40, 167, 69, 0.7));
	animation: success-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.status-badge.status-success .status-icon circle {
	stroke: currentColor;
	fill: rgba(40, 167, 69, 0.1);
	stroke-width: 2;
}

.status-badge.status-success .status-icon path {
	stroke: currentColor;
	stroke-width: 2.5;
	stroke-linecap: round;
	stroke-linejoin: round;
	fill: none;
	stroke-dasharray: 20;
	stroke-dashoffset: 20;
	animation: checkmark-draw 0.6s ease-out 0.2s forwards;
}

/* Error Status - X Mark */
.status-badge.status-error .status-icon {
	color: #dc3545;
	filter: drop-shadow(0 0 8px rgba(220, 53, 69, 0.6));
	animation: error-shake 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.status-badge.status-error .status-icon circle {
	stroke: currentColor;
	fill: rgba(220, 53, 69, 0.1);
	stroke-width: 2;
}

.status-badge.status-error .status-icon path {
	stroke: currentColor;
	stroke-width: 2.5;
	stroke-linecap: round;
	stroke-linejoin: round;
	fill: none;
	stroke-dasharray: 20;
	stroke-dashoffset: 20;
	animation: xmark-draw 0.4s ease-out 0.1s forwards;
}

/* Animations */
@keyframes compiling-spin {
	0% {
		transform: rotate(0deg);
	}
	100% {
		transform: rotate(360deg);
	}
}

@keyframes compiling-dash {
	0%, 100% {
		stroke-dashoffset: 0;
		opacity: 1;
	}
	50% {
		stroke-dashoffset: -30;
		opacity: 0.7;
	}
}

@keyframes success-pop {
	0% {
		transform: scale(0);
		opacity: 0;
	}
	50% {
		transform: scale(1.15);
	}
	100% {
		transform: scale(1);
		opacity: 1;
	}
}

@keyframes checkmark-draw {
	to {
		stroke-dashoffset: 0;
	}
}

@keyframes error-shake {
	0%, 100% {
		transform: translateX(0) scale(1);
	}
	25% {
		transform: translateX(-3px) scale(1.05);
	}
	75% {
		transform: translateX(3px) scale(1.05);
	}
}

@keyframes xmark-draw {
	to {
		stroke-dashoffset: 0;
	}
}

/* Continuous glow effect for success */
.status-badge.status-success .status-icon {
	animation: success-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
	           success-glow-pulse 2s ease-in-out infinite 0.5s;
}

@keyframes success-glow-pulse {
	0%, 100% {
		filter: drop-shadow(0 0 10px rgba(40, 167, 69, 0.7));
	}
	50% {
		filter: drop-shadow(0 0 16px rgba(52, 208, 88, 0.9));
	}
}

/* Continuous glow effect for compiling */
.status-badge.status-compiling .status-icon {
	animation: compiling-spin 1.5s linear infinite,
	           compiling-glow-pulse 2s ease-in-out infinite;
}

@keyframes compiling-glow-pulse {
	0%, 100% {
		filter: drop-shadow(0 0 8px rgba(255, 193, 7, 0.6));
	}
	50% {
		filter: drop-shadow(0 0 14px rgba(255, 193, 7, 0.9));
	}
}

/* Continuous glow effect for error */
.status-badge.status-error .status-icon {
	animation: error-shake 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
	           error-glow-pulse 1.5s ease-in-out infinite 0.5s;
}

@keyframes error-glow-pulse {
	0%, 100% {
		filter: drop-shadow(0 0 8px rgba(220, 53, 69, 0.6));
	}
	50% {
		filter: drop-shadow(0 0 12px rgba(220, 53, 69, 0.8));
	}
}

/* ============================================================================
   MAIN CONTAINER
   ============================================================================ */

/* ── Project Tab Bar ─────────────────────────────────────── */

.project-tab-bar {
	display: flex;
	align-items: center;
	gap: 0;
	background: var(--theme-bg-secondary, #1a1a2e);
	border-bottom: 1px solid var(--theme-border-primary, #333);
	height: 32px;
	min-height: 32px;
	padding: 0 0.5rem;
	overflow-x: auto;
	flex-shrink: 0;
}

.project-tab {
	display: flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0 0.75rem;
	height: 100%;
	font-size: 0.8rem;
	color: #888;
	cursor: pointer;
	border-right: 1px solid var(--theme-border-primary, #333);
	white-space: nowrap;
	max-width: 180px;
	transition: background 0.15s, color 0.15s;
	user-select: none;
}

.project-tab:hover {
	background: var(--theme-bg-tertiary, #2a2a3e);
	color: var(--theme-text-primary, #e0e0e0);
}

.project-tab-active {
	color: var(--theme-text-primary, #e0e0e0);
	background: var(--theme-bg-primary, #0d1117);
	border-bottom: 2px solid var(--theme-text-accent, #4ec9b0);
}

.project-tab-name {
	overflow: hidden;
	text-overflow: ellipsis;
}

.project-tab-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #f38ba8;
	flex-shrink: 0;
}

.project-tab-close {
	background: none;
	border: none;
	color: inherit;
	font-size: 1rem;
	line-height: 1;
	padding: 0 0.15rem;
	cursor: pointer;
	opacity: 0;
	transition: opacity 0.15s;
}

.project-tab:hover .project-tab-close {
	opacity: 0.7;
}

.project-tab-close:hover {
	opacity: 1;
	color: #f38ba8;
}

/* Adjust main container height when tabs are visible */
body.tabs-visible .main-container {
	height: calc(100vh - 50px - 32px);
	height: calc(100dvh - 50px - 32px);
}

.main-container {
	display: flex;
	position: relative;
	top: 0;
	left: 0;
	height: calc(100vh - 50px);
	height: calc(100dvh - 50px);
	min-height: 0;
	min-width: 0;
	overflow: hidden;
	transition: padding-bottom 0.2s ease;
	padding-bottom: 0;
}

/* Adjust layout when AI chat is open - add padding to prevent overlap */
body.ai-chat-open .main-container {
	padding-bottom: 260px;
}

/* ============================================================================
   SIDEBAR
   ============================================================================ */

.sidebar {
	position: relative;
	top: 0;
	left: 0;
	flex: 0 0 250px;
	min-width: 150px;
	max-width: 600px;
	background: #252526;
	border-right: 1px solid #3e3e42;
	overflow-y: auto;
	transition: flex 0.2s ease;
	display: flex;
	flex-direction: column;
}

.sidebar.collapsed {
	flex: 0 0 0;
	min-width: 0;
	max-width: 0;
	overflow: hidden;
	border-right: none;
}

.sidebar-header {
	padding: 1rem;
	background: #2d2d30;
	border-bottom: 1px solid #3e3e42;
}

.sidebar-title-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 0.5rem;
}

.sidebar-title {
	color: #ccc;
	font-size: 0.9rem;
	font-weight: 600;
}

.sidebar-actions {
	display: flex;
	gap: 0.25rem;
}

.sidebar-action-btn {
	background: transparent;
	border: 1px solid #3e3e42;
	border-radius: 4px;
	padding: 0.25rem 0.5rem;
	cursor: pointer;
	color: #ccc;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s;
}

.sidebar-action-btn:hover {
	background: #37373d;
	border-color: #4ec9b0;
	color: #4ec9b0;
}

.sidebar-action-btn:active {
	background: #2a2d2e;
}

/* ============================================================================
   CREATE ITEM MODAL
   ============================================================================ */

.create-item-modal {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 10000;
	display: flex;
	align-items: center;
	justify-content: center;
}

.create-item-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.6);
	backdrop-filter: blur(4px);
}

.create-item-dialog {
	position: relative;
	background: #2d2d30;
	border: 1px solid #3e3e42;
	border-radius: 8px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
	min-width: 400px;
	max-width: 500px;
	width: 90%;
	z-index: 1;
	animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
	from {
		opacity: 0;
		transform: scale(0.95) translateY(-10px);
	}
	to {
		opacity: 1;
		transform: scale(1) translateY(0);
	}
}

.create-item-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 1.25rem 1.5rem;
	border-bottom: 1px solid #3e3e42;
}

.create-item-header h3 {
	margin: 0;
	color: #e0e0e0;
	font-size: 1.1rem;
	font-weight: 600;
}

.create-item-close {
	background: transparent;
	border: none;
	color: #999;
	font-size: 1.75rem;
	cursor: pointer;
	padding: 0;
	width: 28px;
	height: 28px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 4px;
	transition: all 0.2s;
	line-height: 1;
}

.create-item-close:hover {
	background: rgba(231, 76, 60, 0.1);
	color: #e74c3c;
}

.create-item-body {
	padding: 1.5rem;
}

.create-item-path {
	margin-bottom: 1rem;
	color: #999;
	font-size: 0.85rem;
}

.create-item-path span {
	color: #4ec9b0;
	font-weight: 500;
}

.create-item-input {
	width: 100%;
	padding: 0.75rem 1rem;
	background: #1e1e1e;
	border: 1px solid #3e3e42;
	border-radius: 6px;
	color: #e0e0e0;
	font-size: 0.95rem;
	font-family: inherit;
	transition: all 0.2s;
}

.create-item-input:focus {
	outline: none;
	border-color: #4ec9b0;
	box-shadow: 0 0 0 3px rgba(78, 201, 176, 0.1);
}

.create-item-hint {
	margin-top: 0.75rem;
	color: #999;
	font-size: 0.85rem;
}

.create-item-footer {
	display: flex;
	justify-content: flex-end;
	gap: 0.75rem;
	padding: 1rem 1.5rem;
	border-top: 1px solid #3e3e42;
}

.create-item-btn {
	padding: 0.6rem 1.25rem;
	border: none;
	border-radius: 6px;
	font-size: 0.9rem;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s;
	font-family: inherit;
}

.create-item-btn-secondary {
	background: #3c3c3c;
	color: #ccc;
}

.create-item-btn-secondary:hover {
	background: #454545;
	color: #e0e0e0;
}

.create-item-btn-primary {
	background: #4ec9b0;
	color: #1e1e1e;
}

.create-item-btn-primary:hover {
	background: #5dd4c1;
	box-shadow: 0 2px 8px rgba(78, 201, 176, 0.3);
}

.create-item-btn-primary:active {
	transform: scale(0.98);
}

/* ── Template Conflict Dialog ── */

.conflict-dialog {
	max-width: 520px;
}

.conflict-banner {
	display: flex;
	align-items: flex-start;
	gap: 0.65rem;
	padding: 0.75rem 1rem;
	background: rgba(231, 196, 60, 0.08);
	border: 1px solid rgba(231, 196, 60, 0.2);
	border-radius: 6px;
	color: #e7c43c;
	font-size: 0.9rem;
	line-height: 1.5;
	margin-bottom: 0.75rem;
}

.conflict-banner svg {
	flex-shrink: 0;
	margin-top: 2px;
}

.conflict-banner span {
	color: #ccc;
}

.conflict-banner strong {
	color: #e0e0e0;
}

.conflict-file-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
}

.conflict-file-list li {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.45rem 0.75rem;
	background: rgba(255, 255, 255, 0.04);
	border-radius: 5px;
	color: #ccc;
	font-size: 0.88rem;
	font-family: 'Consolas', 'Monaco', monospace;
}

.conflict-file-icon {
	font-size: 0.85rem;
	opacity: 0.7;
}

.conflict-footer {
	justify-content: space-between;
}

.conflict-actions-right {
	display: flex;
	gap: 0.5rem;
}

.conflict-btn-overwrite {
	background: rgba(231, 76, 60, 0.15);
	color: #e74c3c;
	border: 1px solid rgba(231, 76, 60, 0.3);
}

.conflict-btn-overwrite:hover {
	background: rgba(231, 76, 60, 0.25);
	color: #ff6b5a;
	border-color: rgba(231, 76, 60, 0.5);
}

.conflict-btn-overwrite:active {
	transform: scale(0.98);
}

.conflict-new-project-row {
	padding: 0 1.5rem 1rem;
}

.conflict-btn-new-project {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	background: rgba(78, 201, 176, 0.08);
	color: #4ec9b0;
	border: 1px solid rgba(78, 201, 176, 0.25);
	padding: 0.6rem 1rem;
}

.conflict-btn-new-project:hover {
	background: rgba(78, 201, 176, 0.15);
	color: #5dd4c1;
	border-color: rgba(78, 201, 176, 0.4);
}

.conflict-btn-new-project:active {
	transform: scale(0.99);
}

/* ============================================================================
   CONTEXT MENU
   ============================================================================ */

.context-menu {
	background: #2d2d30;
	border: 1px solid #3e3e42;
	border-radius: 6px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
	min-width: 180px;
	overflow: visible;
	animation: contextMenuSlideIn 0.15s ease-out;
}

@keyframes contextMenuSlideIn {
	from {
		opacity: 0;
		transform: scale(0.95) translateY(-5px);
	}
	to {
		opacity: 1;
		transform: scale(1) translateY(0);
	}
}

.context-menu-item {
	padding: 0.6rem 1rem;
	color: #e0e0e0;
	font-size: 0.9rem;
	cursor: pointer;
	transition: all 0.15s;
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.context-menu-item:hover {
	background: #37373d;
	color: #4ec9b0;
}

.context-menu-item:active {
	background: #2a2d2e;
}

.search-box {
	width: 100%;
	padding: 0.5rem;
	background: #3c3c3c;
	border: 1px solid #4e4e52;
	border-radius: 4px;
	color: white;
	font-size: 0.85rem;
}

.search-box:focus {
	outline: none;
	border-color: #4ec9b0;
}

.file-list {
	padding: 0.5rem;
	position: relative;
	z-index: 4;
	transition: outline 0.2s, background 0.2s;
	flex: 1;
	min-height: 0;
}

.file-list.drag-over {
	outline: 2px dashed #4fc3f7;
	outline-offset: -4px;
	background: rgba(79, 195, 247, 0.05);
}

.upload-context-menu {
	background: var(--theme-bg-secondary, #2d2d30);
	border: 1px solid var(--theme-border-primary, #3e3e42);
	border-radius: 6px;
	padding: 4px 0;
	min-width: 160px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.upload-menu-item {
	padding: 8px 14px;
	cursor: pointer;
	font-size: 0.85rem;
	color: var(--theme-text, #ccc);
	white-space: nowrap;
}

.upload-menu-item:hover {
	background: var(--theme-bg-hover, rgba(255, 255, 255, 0.08));
}

.file-item {
	padding: 0.6rem 0.75rem;
	margin: 0.25rem 0;
	background: transparent;
	border-radius: 4px;
	cursor: pointer;
	transition: all 0.2s;
	color: #ccc;
	font-size: 0.85rem;
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.file-item:hover {
	background: #2a2d2e;
}

.file-item.active {
	background: #37373d;
	color: white;
	border-left: 2px solid #4ec9b0;
}

.file-item.selected {
	background: rgba(78, 201, 176, 0.12);
	border-left: 2px solid rgba(78, 201, 176, 0.5);
	color: #e0e0e0;
}

.file-item.selected.active {
	background: #37373d;
	border-left: 2px solid #4ec9b0;
}

.file-icon {
	width: 16px;
	height: 16px;
}

/* ============================================================================
   FOLDER STYLES
   ============================================================================ */

.folder-item {
	margin-bottom: 4px;
}

.folder-header {
	padding: 0.6rem 0.75rem;
	margin: 0.25rem 0;
	background: transparent;
	border-radius: 4px;
	cursor: pointer;
	transition: all 0.2s;
	color: #ccc;
	font-size: 0.85rem;
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.folder-header:hover {
	background: #2a2d2e;
}

.folder-icon {
	width: 16px;
	height: 16px;
}

.folder-arrow {
	margin-left: auto;
	font-size: 0.8em;
	transition: transform 0.2s ease;
}

.folder-content {
	margin-left: 20px;
	margin-top: 2px;
}

.folder-content .file-item,
.folder-content .folder-header {
	background: transparent;
}

.folder-content .file-item:hover,
.folder-content .folder-header:hover {
	background: #2a2d2e;
}

.file-item.subfolder,
.folder-item.subfolder {
	font-size: 0.85em;
}

/* ============================================================================
   TOPIC BLOCKS AND FOLDER ORGANIZATION
   ============================================================================ */

.topic-block {
	margin-bottom: 0.75rem;
	border: 1px solid #3e3e42;
	border-radius: 4px;
	background: #2a2d2e;
}

.topic-block-header {
	padding: 0.5rem 0.75rem;
	display: flex;
	align-items: center;
	gap: 0.5rem;
	border-bottom: 1px solid #3e3e42;
	color: #ccc;
	font-size: 0.85rem;
	font-weight: 600;
}

.topic-block-icon {
	font-size: 1rem;
}

.topic-block-name {
	flex: 1;
}

.topic-block-actions {
	display: flex;
	gap: 0.25rem;
}

.topic-block-btn {
	background: transparent;
	border: none;
	color: #999;
	cursor: pointer;
	padding: 0.25rem 0.5rem;
	border-radius: 3px;
	font-size: 1rem;
	line-height: 1;
	transition: all 0.2s;
}

.topic-block-btn:hover {
	background: #3e3e42;
	color: #ccc;
}

.topic-block-content {
	padding: 0.25rem;
}

.folder-item.in-topic-block {
	margin-bottom: 2px;
}

.folder-drag-handle {
	cursor: grab;
	color: #666;
	font-size: 0.7rem;
	line-height: 1;
	margin-right: 0.25rem;
	user-select: none;
}

.folder-drag-handle:active {
	cursor: grabbing;
}

.folder-item.dragging {
	opacity: 0.5;
}

.folder-item.drag-over {
	background: rgba(78, 201, 176, 0.1);
	border-left: 2px solid #4ec9b0;
}

.folder-menu-btn {
	background: transparent;
	border: none;
	color: #666;
	cursor: pointer;
	padding: 0.25rem 0.5rem;
	border-radius: 3px;
	font-size: 1rem;
	line-height: 1;
	transition: all 0.2s;
	margin-left: auto;
	opacity: 0;
}

.folder-header:hover .folder-menu-btn {
	opacity: 1;
}

.folder-menu-btn:hover {
	background: #3e3e42;
	color: #ccc;
}

.file-drag-handle {
	cursor: grab;
	color: #666;
	font-size: 0.7rem;
	line-height: 1;
	margin-right: 0.25rem;
	user-select: none;
}

.file-drag-handle:active {
	cursor: grabbing;
}

.file-item.dragging {
	opacity: 0.5;
}

.file-item.drag-over {
	background: rgba(78, 201, 176, 0.1);
	border-left: 2px solid #4ec9b0;
}

.file-menu-btn {
	background: transparent;
	border: none;
	color: #666;
	cursor: pointer;
	padding: 0.25rem 0.5rem;
	border-radius: 3px;
	font-size: 1rem;
	line-height: 1;
	transition: all 0.2s;
	margin-left: auto;
	opacity: 0;
}

.file-item:hover .file-menu-btn {
	opacity: 1;
}

.file-menu-btn:hover {
	background: #3e3e42;
	color: #ccc;
}

.file-item.in-topic-block {
	margin-left: 0.5rem;
}

.topic-block-content {
	padding: 0.25rem;
}

.context-menu {
	position: fixed;
	background: white;
	border: 1px solid #ddd;
	border-radius: 6px;
	box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
	z-index: 10001;
	padding: 0.35rem 0;
	min-width: 190px;
	max-width: 250px;
}

.context-menu-category {
	padding: 0.3rem 0.85rem;
	font-size: 0.7rem;
	font-weight: 600;
	color: #888;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	background: #f8f8f8;
	border-bottom: 1px solid #e8e8e8;
	user-select: none;
}

.context-menu-separator {
	height: 1px;
	background: #e8e8e8;
	margin: 0.35rem 0;
}

/* ── Submenu (flyout) ── */

.context-submenu-trigger {
	position: relative;
	justify-content: space-between;
}

.context-submenu-arrow {
	margin-left: auto;
	opacity: 0.5;
	font-size: 0.75rem;
}

.context-submenu {
	display: none;
	position: absolute;
	top: 0;
	right: 100%;
	margin-right: 2px;
	background: #2d2d30;
	border: 1px solid #3e3e42;
	border-radius: 6px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
	min-width: 160px;
	max-height: 260px;
	overflow-y: auto;
	z-index: 10002;
	padding: 0.25rem 0;
}

.context-submenu.visible {
	display: block;
	animation: contextMenuSlideIn 0.12s ease-out;
}

/* Fall back to right side when no space on left */
.context-submenu.context-submenu-right {
	right: auto;
	left: 100%;
	margin-right: 0;
	margin-left: 2px;
}

/* Force dark-theme colors for submenu items (override later light-theme rules) */
.context-submenu .context-menu-item {
	color: #e0e0e0;
}

.context-submenu .context-menu-item:hover {
	background: #37373d;
	color: #4ec9b0;
}

.context-menu-item {
	padding: 0.4rem 0.85rem;
	cursor: pointer;
	color: #333;
	font-size: 0.8rem;
	transition: all 0.12s ease;
	display: flex;
	align-items: center;
	gap: 0.5rem;
	user-select: none;
}

.context-menu-item:hover {
	background: #f0f0f0;
	color: #000;
}

.context-menu-item:active {
	background: #e5e5e5;
}

/* Special item styles */
.context-menu-item-warning {
	color: #d97706;
}

.context-menu-item-warning:hover {
	background: #fef3c7;
	color: #d97706;
}

.context-menu-item-danger {
	color: #dc2626;
}

.context-menu-item-danger:hover {
	background: #fee2e2;
	color: #dc2626;
}

/* ============================================================================
   SPLIT PANEL
   ============================================================================ */

.split-panel {
	display: flex;
	flex: 1;
	position: relative;
	top: 0;
	left: 0;
	min-height: 0;
	min-width: 0;
	overflow: visible;
}

.editor-pane, .preview-pane {
	position: relative;
	top: 0;
	left: 0;
	height: 100%;
	min-height: 0;
	min-width: 0;
	overflow: visible;
}

.editor-pane {
	flex: 1;
	display: flex;
	flex-direction: column;
	background: #1e1e1e;
	transition: flex 0.2s ease;
}

.editor-pane.collapsed {
	flex: 0 0 0;
	min-width: 0;
	max-width: 0;
	overflow: hidden;
}

.preview-pane {
	flex: 1;
	background: #2d2d30;
	border-left: 1px solid #3e3e42;
	display: flex;
	flex-direction: column;
	transition: flex 0.2s ease;
	position: relative;
	top: 0;
	left: 0;
	z-index: 5;
}

.preview-pane.collapsed {
	flex: 0 0 0;
	min-width: 0;
	max-width: 0;
	overflow: hidden;
	border-left: none;
}

.preview-content {
	flex: 1;
	display: flex;
	flex-direction: column;
	height: 100%;
	min-height: 0;
	position: relative;
}

.preview-panel {
	flex: 1;
	display: none;
	min-height: 0;
	width: 100%;
}

.preview-panel.active {
	display: flex;
}

.pdf-panel {
	flex-direction: column;
}

.log-panel {
	flex-direction: column;
	align-items: stretch;
	padding: 1rem 1.25rem;
	gap: 0.75rem;
	overflow: auto;
}

.pane-title-group {
	display: flex !important;
	align-items: center;
	gap: 0.75rem;
	flex-shrink: 0;
}

.pane-tabs {
	display: inline-flex !important;
	align-items: center;
	gap: 0.25rem;
	background: #1f1f22;
	border: 1px solid #3e3e42;
	border-radius: 8px;
	padding: 2px;
	flex-shrink: 0;
}

.pane-tab {
	border: none;
	background: transparent;
	color: #cbd5e1;
	padding: 0.35rem 0.7rem;
	border-radius: 6px;
	cursor: pointer;
	font-size: 0.85rem;
	transition: background 0.15s ease, color 0.15s ease;
}

.pane-tab:hover {
	background: #2f3440;
}

.pane-tab.active {
	background: #4ec9b0;
	color: #0d1b2a;
}

.pane-actions {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.pane-actions-tools {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	margin-right: 0.35rem;
}

.pane-tool-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 7px;
	border: 1px solid #3e3e42;
	background: #26262b;
	color: #e5e7eb;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.pane-tool-btn:hover {
	background: #35353c;
	border-color: #4ec9b0;
	color: #4ec9b0;
}

.pane-tool-btn:active {
	transform: translateY(1px) scale(0.98);
}

.pane-tool-icon {
	width: 18px;
	height: 18px;
	display: block;
}

.pane-tool-icon.spin-once {
	animation: paneToolSpin 0.6s ease;
	transform-origin: 50% 50%;
}

.pane-tool-btn.press-once {
	animation: paneToolPress 0.32s ease;
}

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

@keyframes paneToolPress {
	0% { transform: translateY(0) scale(1); }
	40% { transform: translateY(2px) scale(0.97); }
	100% { transform: translateY(0) scale(1); }
}

.pane-header {
	padding: 0.75rem 1rem;
	background: #2d2d30;
	border-bottom: 1px solid #3e3e42;
	color: #ccc;
	font-size: 0.85rem;
	display: flex !important;
	justify-content: space-between;
	align-items: center;
	position: relative;
	z-index: 5;
	min-height: 50px;
	flex-shrink: 0;
}

.pane-header h3 {
	font-size: 0.9rem;
	font-weight: 600;
}

.pane-actions {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.pane-icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border-radius: 8px;
	border: 1px solid #3e3e42;
	background: #2d2d30;
	color: #e5e7eb;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.pane-icon-btn:hover,
.pane-icon-btn.active {
	background: #3e3e42;
	border-color: #4ec9b0;
	color: #4ec9b0;
}

.pane-icon-btn svg {
	width: 18px;
	height: 18px;
}

/* ============================================================================
   CODE EDITOR
   ============================================================================ */

.code-editor {
	flex: 1;
	min-height: 0;
	overflow: visible;
	background: #1e1e1e;
	position: relative;
}

#monaco-editor {
	width: 100%;
	height: 100%;
}

.monaco-editor,
.monaco-editor .overflow-guard {
	overflow: visible !important;
}

/* ============================================================================
   PDF VIEWER
   ============================================================================ */

.pdf-viewer {
	flex: 1;
	background: #525252;
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
	overflow: hidden;
	pointer-events: auto;
	z-index: 1;
}

.pdf-frame {
	width: 100%;
	height: 100%;
	border: none;
	position: absolute;
	top: 0;
	left: 0;
}

.pdf-frame.fade-in {
	transition: opacity 1.5s ease-in-out;
}

.pdf-placeholder {
	text-align: center;
	color: #999;
	padding: 3rem;
}

.pdf-placeholder svg {
	width: 80px;
	height: 80px;
	margin-bottom: 1rem;
	opacity: 0.5;
}

/* ============================================================================
   LOADING OVERLAY
   ============================================================================ */

.loading-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(45, 45, 48, 0.95);
	display: none;
	align-items: center;
	justify-content: center;
	z-index: 10;
	pointer-events: none;
}

.loading-overlay.active {
	display: flex;
}

.loading-content {
	text-align: center;
	color: white;
}

.spinner {
	border: 4px solid #3e3e42;
	border-top: 4px solid #4ec9b0;
	border-radius: 50%;
	width: 50px;
	height: 50px;
	animation: spin 1s linear infinite;
	margin: 0 auto 1rem;
}

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

/* ============================================================================
   NOTIFICATIONS
   ============================================================================ */

.notification {
	position: fixed;
	top: 65px;
	right: 20px;
	padding: 0.5rem 0.75rem;
	background: rgba(45, 45, 48, 0.9);
	backdrop-filter: blur(10px);
	border-radius: 20px;
	box-shadow: 0 2px 8px rgba(0,0,0,0.3);
	color: white;
	z-index: 2000;
	display: none;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.8rem;
	border: 1px solid rgba(255, 255, 255, 0.1);
}

.notification.active {
	display: flex;
	animation: subtleFadeIn 0.4s ease;
}

.notification.success {
	border-color: rgba(40, 167, 69, 0.3);
}

.notification.error {
	border-color: rgba(220, 53, 69, 0.3);
}

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

/* ============================================================================
   RESIZER
   ============================================================================ */

.resizer {
	width: 5px;
	background: #3e3e42;
	cursor: col-resize;
	position: relative;
	flex-shrink: 0;
	z-index: 5;
}

.resizer:hover {
	background: #4ec9b0;
}

.sidebar.collapsed ~ .sidebar-resizer:not(.force-visible) {
	display: none;
}

.editor-pane.collapsed ~ .resizer:not(.force-visible),
.preview-pane.collapsed ~ .resizer:not(.force-visible) {
	display: none;
}

.split-panel:has(.editor-pane.collapsed) .resizer:not(.force-visible),
.split-panel:has(.preview-pane.collapsed) .resizer:not(.force-visible) {
	display: none;
}

.resizer.force-visible {
	display: block !important;
	width: 16px !important;
	background: #4ec9b0 !important;
	opacity: 0.9;
	transition: width 0.2s ease, background 0.2s ease, opacity 0.2s ease;
}

.resizer.force-visible:hover {
	background: #4ec9b0 !important;
	opacity: 1;
	width: 15px !important;
}

/* ============================================================================
   SYNTAX HIGHLIGHTING
   ============================================================================ */

.latex-command { color: #c678dd; }
.latex-comment { color: #6a9955; font-style: italic; }
.latex-bracket { color: #e06c75; }
.latex-string { color: #ce9178; }

/* ============================================================================
   GLOBAL SCROLLBAR STYLES - Modern, Subtle & Elegant
   ============================================================================ */

/* Fade-in animation for scrollbar */
@keyframes scrollbarFadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

/* Alternative fade-in with ease-in-out */
@keyframes scrollbarFadeInEase {
	0% {
		opacity: 0;
	}
	50% {
		opacity: 0.5;
	}
	100% {
		opacity: 1;
	}
}

/* Webkit browsers (Chrome, Safari, Edge) */
*::-webkit-scrollbar {
	width: 10px;
	height: 10px;
}

*::-webkit-scrollbar-track {
	background: transparent;
	border-radius: 10px;
}

*::-webkit-scrollbar-thumb {
	background: rgba(78, 201, 176, 0.3);
	border-radius: 10px;
	border: 2px solid transparent;
	background-clip: padding-box;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	animation: scrollbarFadeIn 0.6s ease-out;
	opacity: 0;
	animation-fill-mode: forwards;
}

*::-webkit-scrollbar-thumb:hover {
	background: rgba(78, 201, 176, 0.7);
	background-clip: padding-box;
	box-shadow: 0 0 10px rgba(78, 201, 176, 0.3);
}

*::-webkit-scrollbar-thumb:active {
	background: rgba(78, 201, 176, 0.8);
	background-clip: padding-box;
	box-shadow: 0 0 15px rgba(78, 201, 176, 0.4);
}

*::-webkit-scrollbar-corner {
	background: transparent;
}

/* Firefox */
* {
	scrollbar-width: thin;
	scrollbar-color: rgba(78, 201, 176, 0.3) transparent;
}

/* Enhanced scrollbar for specific containers */
.sidebar::-webkit-scrollbar-thumb,
.settings-content::-webkit-scrollbar-thumb,
.latex-toolbar-dropdown::-webkit-scrollbar-thumb {
	background: rgba(78, 201, 176, 0.35);
	background-clip: padding-box;
	animation: scrollbarFadeIn 0.6s ease-out;
	animation-fill-mode: forwards;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.settings-content::-webkit-scrollbar-thumb:hover,
.latex-toolbar-dropdown::-webkit-scrollbar-thumb:hover {
	background: rgba(78, 201, 176, 0.7);
	background-clip: padding-box;
	box-shadow: 0 0 12px rgba(78, 201, 176, 0.35);
}

.sidebar::-webkit-scrollbar-thumb:active,
.settings-content::-webkit-scrollbar-thumb:active,
.latex-toolbar-dropdown::-webkit-scrollbar-thumb:active {
	background: rgba(78, 201, 176, 0.8);
	background-clip: padding-box;
	box-shadow: 0 0 18px rgba(78, 201, 176, 0.45);
}

/* Firefox specific containers */
.sidebar,
.settings-content,
.latex-toolbar-dropdown {
	scrollbar-color: rgba(78, 201, 176, 0.35) transparent;
}

/* Smooth scrolling glow effect on scroll */
@keyframes scrollGlow {
	0% {
		box-shadow: 0 0 10px rgba(78, 201, 176, 0.3);
	}
	50% {
		box-shadow: 0 0 18px rgba(78, 201, 176, 0.5);
	}
	100% {
		box-shadow: 0 0 10px rgba(78, 201, 176, 0.3);
	}
}

/* Apply glow when scrolling (via JavaScript class) */
.scrolling::-webkit-scrollbar-thumb {
	animation: scrollGlow 1.5s ease-in-out infinite;
	background: rgba(78, 201, 176, 0.55) !important;
	background-clip: padding-box;
}

/* Enhanced visibility for scrolling state */
.scrolling::-webkit-scrollbar-thumb:hover {
	background: rgba(78, 201, 176, 0.7) !important;
}

.scrolling::-webkit-scrollbar-thumb:active {
	background: rgba(78, 201, 176, 0.8) !important;
}

/* Monaco Editor scrollbar styling */
.monaco-scrollable-element > .scrollbar > .slider {
	background: rgba(78, 201, 176, 0.3) !important;
	transition: background 0.2s ease, opacity 0.8s ease-in-out !important;
	opacity: 0 !important;
}

/* When scrollbar is visible, fade in smoothly */
.monaco-scrollable-element > .scrollbar.visible > .slider {
	opacity: 1 !important;
	transition: opacity 0.8s ease-in-out !important;
}

/* Ensure visibility for vertical and horizontal scrollbars */
.monaco-scrollable-element > .scrollbar.visible.vertical > .slider,
.monaco-scrollable-element > .scrollbar.visible.horizontal > .slider {
	opacity: 1 !important;
	transition: opacity 0.8s ease-in-out !important;
}

/* Fade-in animation class - starts from 0 and animates to 1 */
.monaco-scrollable-element > .scrollbar > .slider.fade-in {
	animation: scrollbarFadeIn 0.8s ease-in-out forwards !important;
}

.monaco-scrollable-element > .scrollbar > .slider:hover {
	background: rgba(78, 201, 176, 0.7) !important;
	box-shadow: 0 0 10px rgba(78, 201, 176, 0.3) !important;
	opacity: 1 !important;
}

.monaco-scrollable-element > .scrollbar > .slider:active {
	background: rgba(78, 201, 176, 0.8) !important;
	box-shadow: 0 0 15px rgba(78, 201, 176, 0.4) !important;
	opacity: 1 !important;
}

/* Monaco editor scrolling state - make scrollbar more visible when scrolling */
.monaco-scrollable-element.scrolling > .scrollbar > .slider {
	background: rgba(78, 201, 176, 0.55) !important;
	box-shadow: 0 0 12px rgba(78, 201, 176, 0.4) !important;
	animation: scrollGlow 1.5s ease-in-out infinite !important;
}

/* PDF viewer iframe scrollbar (if accessible) */
.pdf-frame::-webkit-scrollbar {
	width: 10px;
	height: 10px;
}

.pdf-frame::-webkit-scrollbar-track {
	background: transparent;
	border-radius: 10px;
}

.pdf-frame::-webkit-scrollbar-thumb {
	background: rgba(78, 201, 176, 0.35);
	border-radius: 10px;
	border: 2px solid transparent;
	background-clip: padding-box;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	animation: scrollbarFadeIn 0.6s ease-out;
	animation-fill-mode: forwards;
}

.pdf-frame::-webkit-scrollbar-thumb:hover {
	background: rgba(78, 201, 176, 0.7);
	background-clip: padding-box;
	box-shadow: 0 0 12px rgba(78, 201, 176, 0.35);
}

.pdf-frame::-webkit-scrollbar-thumb:active {
	background: rgba(78, 201, 176, 0.8);
	background-clip: padding-box;
	box-shadow: 0 0 18px rgba(78, 201, 176, 0.45);
}

/* ============================================================================
   SYNCTEX HIGHLIGHT
   ============================================================================ */

.synctex-highlight-line {
	background-color: rgba(78, 201, 176, 0.3) !important;
	animation: synctexPulse 2s ease-out;
}

.synctex-highlight-glyph {
	background-color: rgba(78, 201, 176, 0.6);
	width: 5px !important;
	margin-left: 3px;
}

@keyframes synctexPulse {
	0% {
		background-color: rgba(78, 201, 176, 0.6);
	}
	50% {
		background-color: rgba(78, 201, 176, 0.4);
	}
	100% {
		background-color: rgba(78, 201, 176, 0.3);
	}
}

/* ============================================================================
   PDF.JS TEXT LAYER (for text selection)
   ============================================================================ */

.textLayer {
	position: absolute;
	text-align: initial;
	left: 0;
	top: 0;
	right: 0;
	bottom: 0;
	overflow: hidden;
	opacity: 1;
	line-height: 1;
	-webkit-text-size-adjust: none;
	-moz-text-size-adjust: none;
	text-size-adjust: none;
	forced-color-adjust: none;
	z-index: 2;
	pointer-events: none;
}

.textLayer span,
.textLayer br {
	color: transparent;
	position: absolute;
	white-space: pre;
	cursor: text;
	transform-origin: 0% 0%;
}

.textLayer span.markedContent {
	top: 0;
	height: 0;
}

.textLayer .highlight {
	margin: -1px;
	padding: 1px;
	background-color: rgba(180, 0, 170, 0.2);
	border-radius: 4px;
}

.textLayer .highlight.appended {
	position: initial;
}

.textLayer .highlight.begin {
	border-radius: 4px 0 0 4px;
}

.textLayer .highlight.end {
	border-radius: 0 4px 4px 0;
}

.textLayer .highlight.middle {
	border-radius: 0;
}

.textLayer .highlight.selected {
	background-color: rgba(0, 100, 0, 0.2);
}

/* Text selection styling */
.textLayer ::selection {
	background: rgba(0, 100, 200, 0.3);
}

.textLayer ::-moz-selection {
	background: rgba(0, 100, 200, 0.3);
}

/* Keep the annotation layer on top of the text to allow clickable links */
.pdf-page-canvas {
	pointer-events: none;
	z-index: 1;
}

.annotationLayer {
	pointer-events: none;  /* Let text selection pass through to textLayer below */
	z-index: 5;
}

/* Only link elements within annotation layer intercept clicks */
.annotationLayer a,
.annotationLayer .linkAnnotation {
	pointer-events: auto;
}

/* ============================================================================
   PDF.JS ANNOTATION LAYER (for hyperlinks)
   ============================================================================ */

.annotationLayer section {
	position: absolute;
	text-align: initial;
	pointer-events: auto;
}

.annotationLayer a,
.annotationLayer .linkAnnotation {
	position: absolute;
	font-size: 1em;
}

.annotationLayer a:hover,
.annotationLayer .linkAnnotation:hover {
	background: rgba(255, 255, 0, 0.3);
	box-shadow: 0 2px 10px rgba(255, 255, 0, 0.3);
	cursor: pointer;
}

.annotationLayer .textAnnotation img {
	position: absolute;
	cursor: pointer;
	width: 100%;
	height: 100%;
}

.annotationLayer .textWidgetAnnotation input,
.annotationLayer .textWidgetAnnotation textarea,
.annotationLayer .choiceWidgetAnnotation select,
.annotationLayer .buttonWidgetAnnotation.checkBox input,
.annotationLayer .buttonWidgetAnnotation.radioButton input {
	background-image: none;
	border: 1px solid transparent;
	box-sizing: border-box;
	font: calc(9px * var(--scale-factor)) sans-serif;
	height: 100%;
	margin: 0;
	vertical-align: top;
	width: 100%;
}

.annotationLayer .choiceWidgetAnnotation select option {
	padding: 0;
}

.annotationLayer .buttonWidgetAnnotation.radioButton input {
	border-radius: 50%;
}

.annotationLayer .textWidgetAnnotation textarea {
	resize: none;
}

.annotationLayer .textWidgetAnnotation input[disabled],
.annotationLayer .textWidgetAnnotation textarea[disabled],
.annotationLayer .choiceWidgetAnnotation select[disabled],
.annotationLayer .buttonWidgetAnnotation.checkBox input[disabled],
.annotationLayer .buttonWidgetAnnotation.radioButton input[disabled] {
	background: none;
	border: 1px solid transparent;
	cursor: not-allowed;
}

/* ============================================================================
   ACCESS GATE – Login hint banners
   ============================================================================ */

.access-gate-login-hint {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 4px;
	font-size: 13px;
	line-height: 1.4;
}

.access-gate-login-link {
	color: #61afef;
	text-decoration: underline;
	cursor: pointer;
	font-weight: 500;
	font-size: 13px;
}

.access-gate-login-link:hover {
	color: #8ac6ff;
}

/* Bridge modal login hint */
.bridge-login-hint {
	background: rgba(224, 108, 117, 0.1);
	border: 1px solid rgba(224, 108, 117, 0.3);
	border-radius: 8px;
	padding: 10px 14px;
	margin-bottom: 12px;
	color: #e06c75;
	font-weight: 500;
}

.bridge-login-hint .access-gate-login-link {
	color: #61afef;
}

/* PDF toolbar login hint */
.pane-login-hint {
	font-size: 11px;
	padding: 2px 8px;
	flex-direction: row;
	gap: 4px;
	align-items: center;
	color: #e06c75;
}

.pane-login-hint .access-gate-login-link {
	font-size: 11px;
}
